Miva Claude Sonnet 4.6 commited on
Commit ·
eb063d7
1
Parent(s): 020c63a
feat: outreach tools, language switcher fix, deploy + SMS + email
Browse files- Fix language switcher double-bubble bug (Finnish primary site now
correctly generates index.html as fi, index-en.html as en, with
working links between them)
- Add Quick Demo deploy button (Cloudflare Pages, progress bar)
- Add SMS modal with phone-style UI, Fi/En toggle, WhatsApp link
- Add Email modal with Fi/En toggle, editable subject/body, Gmail link
- Add Interesting star status for prospect tracking
- Add server restart button to dashboard and prospects
- Fix status whitelist to accept 'interesting'
- Add /api/deploy-demo/<osm_id> endpoint for prospect site deploy
- Add Brevo API key to .env for future direct send integration
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Files changed (6)
- app.py+139-24
- db.py+8-4
- generator.py+4-2
- templates/businesses.html+580-24
- templates/dashboard.html+22
- templates/prospects.html+258-24
531 unmodified lines532533534535536537177 unmodified lines71571671771871972072142 unmodified lines7647657667677687697705 unmodified lines7767777787797807816 unmodified lines7887897907917927937946 unmodified lines80180280380480580680711 unmodified lines8198208218228238248258268278286 unmodified lines83583683783883984084195 unmodified lines93793893994094194294394494594694794894995095195295395495595695781 unmodified lines103910401041104210431044104546 unmodified lines10921093109410951096109710981099110011011102110338 unmodified lines11421143114411451146114741 unmodified lines1189119011911192119311941195112 unmodified lines1308130913101311131213131314131513161317131813191320531 unmodified linesreturn jsonify({"job_id": job_id})@app.route("/api/regenerate/<slug>", methods=["POST"])def api_regenerate(slug):client = db.get(slug)177 unmodified linesstatus = d.get("status", "").strip()if not osm_id:return jsonify({"error": "osm_id required"}), 400if status not in ("", "pending", "negative", "customer"):return jsonify({"error": "invalid status"}), 400# Save full business data if providedif d.get("name"):42 unmodified lines@app.route("/api/businesses/<osm_id>/status", methods=["POST"])def api_business_status(osm_id):status = request.get_json(force=True).get("status", "")if status not in ("", "pending", "negative", "customer"):return jsonify({"error": "invalid status"}), 400db.managed_set_status(osm_id, status)return jsonify({"ok": True})5 unmodified linesreturn jsonify({"ok": True})@app.route("/api/prospects/enrich", methods=["POST"])def api_prospects_enrich():import requests as _req, re, urllib.parse, unicodedata6 unmodified lineslng = d.get("lng")osm_id = d.get("osm_id", "")osm_type = d.get("osm_type", "node")country = d.get("country", "hu").lower()_HDR = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/120.0 Safari/537.36"}_NOM_HDR = {"User-Agent": "Sitegen/1.0 (prospect-enricher)"}_WEB_KEYS = ("website", "contact:website", "url", "contact:url", "brand:website")6 unmodified lines# Cache hit: skip all network callsif osm_id:cached = db.enrich_cache_get(osm_id)if cached:return jsonify(cached)11 unmodified lines"budapestindex.com", "budapestguide", "hungarybudapest", "minube.","hungarianfreepress", "buttondown.email", "mastodon.", "booking.com","happycow.net", "openrice.com", "menulog.", "just-eat.", "lieferando.",# Finnish directories / aggregators"eat.fi", "lounaspaikka.fi", "raflaamo.fi", "fonecta.fi", "resto.fi","yelp.fi", "tripadvisor.fi", "visitfinland.com", "visithelsinki.fi","myhelsinki.fi", "nettix.fi", "finder.fi", "yritystele.fi",)def _first(d, keys):6 unmodified linesr'(?:\+358|0)[\s\-./]?\(?\d{1,3}\)?[\s\-./]?\d{3,4}[\s\-./]?\d{3,5}', text)for h in hits:digits = re.sub(r'\D', '', h)if 9 <= len(digits) <= 13:return h.strip()return ""# Hungary (default): +36 / 0695 unmodified linesreturn outdef _pick_website(candidates):"""Prefer .hu TLD, then first candidate."""hu = next((c for c in candidates if c.rstrip('/').endswith('.hu')), "")return hu or (candidates[0] if candidates else "")def _guess_domains(n):"""Yield plausible domain guesses: both hyphenated and joined, .hu first."""slug = _name_to_slug(n)for stop in ("-etterem", "-kavezo", "-cafe", "-restaurant", "-bar","-pizzeria", "-budapest", "-by-", "-es-", "-and-"):slug = slug.replace(stop, "-")slug = slug.strip('-')joined = slug.replace('-', '') # cookiebeacon alongside cookie-beaconvariants = [slug] + ([joined] if joined != slug else [])for v in variants:for tld in (".hu", ".com"):yield f"https://www.{v}{tld}/"yield f"https://{v}{tld}/"81 unmodified lines# ── Phase 4: OSM fallback — only if still missing data ───────────────────if not result["website"] or not result["phone"]:osm_tags = _osm_lookup()result["website"] = result["website"] or _first(osm_tags, _WEB_KEYS)result["phone"] = result["phone"] or _first(osm_tags, _PHONE_KEYS)result["email"] = result["email"] or _first(osm_tags, _EMAIL_KEYS)46 unmodified linessearch_keys = [{"amenity": a} for a in _NOM_DEFAULT_AMENITIES]_WEB_KEYS = ("website", "contact:website", "url", "contact:url","brand:website", "operator:website","facebook", "contact:facebook","instagram", "contact:instagram","twitter", "contact:twitter")_PHONE_KEYS = ("phone", "contact:phone", "contact:mobile", "mobile")_EMAIL_KEYS = ("email", "contact:email")def _first(d, keys):return next((d[k] for k in keys if d.get(k)), "")38 unmodified linesaddr = r.get("address") or {}website_url = _first(ext, _WEB_KEYS)has_website = bool(website_url)if not has_website:no_website_count += 141 unmodified linesif not item["email"]:item["email"] = _first(tags, _EMAIL_KEYS)if not item["website"]:item["website"] = _first(tags, _WEB_KEYS)item["has_website"] = bool(item["website"])except Exception:pass112 unmodified lines(output_dir / f"index-{code}.html").write_text(translated, encoding="utf-8")log(f"Translation done → index-{code}.html")all_codes = ["en"] + [_lang_codes.get(l, l[:2].lower()) for l in translation_languages]if len(all_codes) > 1:log("Injecting language switcher...")for code in all_codes:fname = "index.html" if code == "en" else f"index-{code}.html"fpath = output_dir / fnamepatched = inject_language_switcher(fpath.read_text(encoding="utf-8"), code, all_codes)fpath.write_text(patched, encoding="utf-8")# Re-sync sub-page navs now that index.html has the language switcherfrom generator import _sync_subpage_navs531 unmodified lines532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575177 unmodified lines75375475575675775875942 unmodified lines8028038048058068078085 unmodified lines8148158168178188198208218228238248258268278288296 unmodified lines8368378388398408418426 unmodified lines84985085185285385485511 unmodified lines8678688698708718728738748758768778788798808818828838848858868876 unmodified lines89489589689789889990095 unmodified lines99699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104181 unmodified lines112311241125112611271128112911301131113246 unmodified lines117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121238 unmodified lines1251125212531254125512561257125841 unmodified lines1300130113021303130413051306130713081309112 unmodified lines14221423142414251426142714281429143014311432143314341435531 unmodified linesreturn jsonify({"job_id": job_id})@app.route("/api/deploy-demo/<osm_id>", methods=["POST"])def api_deploy_demo(osm_id):"""Deploy an existing Quick Demo site for a prospect to Cloudflare Pages."""prospect = db.managed_get(osm_id)if not prospect:return jsonify({"error": "prospect not found"}), 404slug = slugify(prospect["name"])output_dir = Path("output") / slugif not output_dir.exists():return jsonify({"error": "site not generated yet — run Quick Demo first"}), 400job_id = uuid.uuid4().hex[:10]with _lock:jobs[job_id] = {"status": "queued", "log": [], "result": None, "error": None, "created_at": time.time()}db.job_upsert(job_id, "queued")def _run():def log(msg, status="deploying"):with _lock:jobs[job_id]["log"].append(msg)jobs[job_id]["status"] = statustry:log("Deploying to Cloudflare Pages...")result = deploy_from_dir(output_dir, slug, business_name=prospect["name"],github=False, cloudflare=True)live_url = result.get("live_url", "")if live_url:log(f"Live → {live_url}")log("Done!", "done")_job_done(job_id, {"slug": slug, "live_url": live_url})except Exception as e:_job_error(job_id, str(e))threading.Thread(target=_run, daemon=True).start()return jsonify({"job_id": job_id})@app.route("/api/regenerate/<slug>", methods=["POST"])def api_regenerate(slug):client = db.get(slug)177 unmodified linesstatus = d.get("status", "").strip()if not osm_id:return jsonify({"error": "osm_id required"}), 400if status not in ("", "pending", "negative", "interesting", "customer"):return jsonify({"error": "invalid status"}), 400# Save full business data if providedif d.get("name"):42 unmodified lines@app.route("/api/businesses/<osm_id>/status", methods=["POST"])def api_business_status(osm_id):status = request.get_json(force=True).get("status", "")if status not in ("", "pending", "negative", "interesting", "customer"):return jsonify({"error": "invalid status"}), 400db.managed_set_status(osm_id, status)return jsonify({"ok": True})5 unmodified linesreturn jsonify({"ok": True})@app.route("/api/restart", methods=["POST"])def api_restart():import subprocess, syspid = os.getpid()cmd = f"sleep 1 && kill {pid} && cd {os.getcwd()} && {sys.executable} app.py >> /tmp/sitegen.log 2>&1 &"subprocess.Popen(cmd, shell=True, stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)return jsonify({"ok": True})@app.route("/api/prospects/enrich", methods=["POST"])def api_prospects_enrich():import requests as _req, re, urllib.parse, unicodedata6 unmodified lineslng = d.get("lng")osm_id = d.get("osm_id", "")osm_type = d.get("osm_type", "node")country = d.get("country", "").lower()_HDR = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 Chrome/120.0 Safari/537.36"}_NOM_HDR = {"User-Agent": "Sitegen/1.0 (prospect-enricher)"}_WEB_KEYS = ("website", "contact:website", "url", "contact:url", "brand:website")6 unmodified lines# Cache hit: skip all network callsif osm_id:cached = db.enrich_cache_get(osm_id, country=country)if cached:return jsonify(cached)11 unmodified lines"budapestindex.com", "budapestguide", "hungarybudapest", "minube.","hungarianfreepress", "buttondown.email", "mastodon.", "booking.com","happycow.net", "openrice.com", "menulog.", "just-eat.", "lieferando.",# Finnish directories / aggregators / news / orgs"eat.fi", "lounaspaikka.fi", "raflaamo.fi", "fonecta.fi", "resto.fi","lounaat.info", "cylex.fi", "yritystele.fi", "finder.fi","visitfinland.com", "visithelsinki.fi", "myhelsinki.fi","aamulehti.fi", "yrittajat.fi", "hs.fi", "iltalehti.fi", "is.fi","mtv.fi", "yle.fi", "kauppalehti.fi", "satakunnankansa.fi", "tyrvaansanomat.fi","nokianuutiset.fi", "nokianlounaat.fi", "luncher.fi", "lounasmenu.fi","magasiini.fi", "asiakastieto.fi", "finlandbusinessdirectory.com","plugshare.com", "jannahtambunan.com",# Apps / utilities (not business sites)"startpage.com", "moovitapp.com", "parkopedia.", "untappd.com","kaljapp.fi", "reddit.com", "semeny.", "holidayclub",# Franchise/chain HQs (not individual business sites)"kotipizza.fi", "hesburger.fi", "subway.com", "restaurants.subway","mcdonalds.", "starbucks.", "dominos.",)def _first(d, keys):6 unmodified linesr'(?:\+358|0)[\s\-./]?\(?\d{1,3}\)?[\s\-./]?\d{3,4}[\s\-./]?\d{3,5}', text)for h in hits:digits = re.sub(r'\D', '', h)if 9 <= len(digits) <= 11:return h.strip()return ""# Hungary (default): +36 / 0695 unmodified linesreturn outdef _pick_website(candidates):"""Filter to domains that contain a business name token; prefer country TLD."""_GENERIC_TOKENS = {"restaurant", "cafe", "bar", "grill", "pizza", "burger", "bistro","kitchen", "etterem", "kavezo", "ravintola", "kahvila", "baari","food", "eat", "dining", "house", "the", "and", "ja",}name_slug = _name_to_slug(name)tokens = [t for t in name_slug.split("-")if t and t not in _GENERIC_TOKENS and len(t) > 2]def _name_in_domain(url):if not tokens:return True # no significant tokens — can't filterdomain = urllib.parse.urlparse(url).netloc.replace("www.", "").lower()return any(t in domain for t in tokens)valid = [c for c in candidates if _name_in_domain(c)]preferred_tld = ".fi" if country == "fi" else ".hu"preferred = next((c for c in valid if c.rstrip('/').endswith(preferred_tld)), "")return preferred or (valid[0] if valid else "")def _guess_domains(n):"""Yield plausible domain guesses: both hyphenated and joined, country TLD first."""slug = _name_to_slug(n)hu_stops = ("-etterem", "-kavezo", "-cafe", "-restaurant", "-bar","-pizzeria", "-budapest", "-by-", "-es-", "-and-")fi_stops = ("-ravintola", "-kahvila", "-baari", "-pizzeria", "-tampere","-helsinki", "-oulu", "-turku", "-ja-", "-and-")stops = fi_stops if country == "fi" else hu_stopsfor stop in stops:slug = slug.replace(stop, "-")slug = slug.strip('-')joined = slug.replace('-', '') # cookiebeacon alongside cookie-beaconvariants = [slug] + ([joined] if joined != slug else [])if country == "fi":tlds = (".fi", ".com")else:tlds = (".hu", ".com")for v in variants:for tld in tlds:yield f"https://www.{v}{tld}/"yield f"https://{v}{tld}/"81 unmodified lines# ── Phase 4: OSM fallback — only if still missing data ───────────────────if not result["website"] or not result["phone"]:osm_tags = _osm_lookup()osm_web = _first(osm_tags, _WEB_KEYS)if osm_web and any(s in osm_web for s in _SKIP_DOMAINS):osm_web = ""result["website"] = result["website"] or osm_webresult["phone"] = result["phone"] or _first(osm_tags, _PHONE_KEYS)result["email"] = result["email"] or _first(osm_tags, _EMAIL_KEYS)46 unmodified linessearch_keys = [{"amenity": a} for a in _NOM_DEFAULT_AMENITIES]_WEB_KEYS = ("website", "contact:website", "url", "contact:url","brand:website", "operator:website")_PHONE_KEYS = ("phone", "contact:phone", "contact:mobile", "mobile")_EMAIL_KEYS = ("email", "contact:email")_SKIP_DOMAINS = ("google.", "facebook.com", "instagram.com", "twitter.com", "x.com","youtube.com", "tripadvisor", "yelp.com", "foursquare", "wikipedia","maps.", "wolt.", "foodora", "gstatic", "tiktok.com", "linkedin.com","w3.org", "schema.org", "schemas.", "microsoft.com", "bing.com", "msn.com","live.com", "windows.com", "openstreetmap.org", "geonames.org", "wikidata.org","apple.com", "amazonaws.com", "cloudflare", "jquery", "bootstrap","jsdelivr", "unpkg.com", "cdnjs", "akamai", "edgekey", "akamaized","etterem.hu", "zomato.com", "thefork.com", "restaurantguru","budapestindex.com", "budapestguide", "hungarybudapest", "minube.","hungarianfreepress", "buttondown.email", "mastodon.", "booking.com","happycow.net", "openrice.com", "menulog.", "just-eat.", "lieferando.","eat.fi", "lounaspaikka.fi", "raflaamo.fi", "fonecta.fi", "resto.fi","lounaat.info", "cylex.fi", "yritystele.fi", "finder.fi","visitfinland.com", "visithelsinki.fi", "myhelsinki.fi","aamulehti.fi", "yrittajat.fi", "hs.fi", "iltalehti.fi", "is.fi","mtv.fi", "yle.fi", "kauppalehti.fi", "satakunnankansa.fi", "tyrvaansanomat.fi","nokianuutiset.fi", "nokianlounaat.fi", "luncher.fi", "lounasmenu.fi","magasiini.fi", "asiakastieto.fi", "finlandbusinessdirectory.com","plugshare.com","startpage.com", "moovitapp.com", "parkopedia.", "untappd.com","kaljapp.fi", "reddit.com", "semeny.", "holidayclub","kotipizza.fi", "hesburger.fi", "subway.com", "restaurants.subway","mcdonalds.", "starbucks.", "dominos.",)def _first(d, keys):return next((d[k] for k in keys if d.get(k)), "")38 unmodified linesaddr = r.get("address") or {}website_url = _first(ext, _WEB_KEYS)if website_url and any(s in website_url for s in _SKIP_DOMAINS):website_url = ""has_website = bool(website_url)if not has_website:no_website_count += 141 unmodified linesif not item["email"]:item["email"] = _first(tags, _EMAIL_KEYS)if not item["website"]:osm_web = _first(tags, _WEB_KEYS)if osm_web and any(s in osm_web for s in _SKIP_DOMAINS):osm_web = ""item["website"] = osm_webitem["has_website"] = bool(item["website"])except Exception:pass112 unmodified lines(output_dir / f"index-{code}.html").write_text(translated, encoding="utf-8")log(f"Translation done → index-{code}.html")primary_code = _lang_codes.get(form.get("site_language", "English (UK)"), "en")all_codes = list(dict.fromkeys([primary_code] + [_lang_codes.get(l, l[:2].lower()) for l in translation_languages]))if len(all_codes) > 1:log("Injecting language switcher...")for code in all_codes:fname = "index.html" if code == primary_code else f"index-{code}.html"fpath = output_dir / fnamepatched = inject_language_switcher(fpath.read_text(encoding="utf-8"), code, all_codes, primary_code=primary_code)fpath.write_text(patched, encoding="utf-8")# Re-sync sub-page navs now that index.html has the language switcherfrom generator import _sync_subpage_navs
233 unmodified lines23423523623723823910 unmodified lines25025125225325425525625725825926026126221 unmodified lines2842852862872882892904 unmodified lines2952962972982993003 unmodified lines3043053063073083093101 unmodified line312313314315316317233 unmodified linesupdated_at = datetime('now')""", (osm_id, status))c.commit()def prospect_get_statuses(osm_ids: list) -> dict:10 unmodified lines# ── Enrich cache ──────────────────────────────────────────────────────────────def enrich_cache_get(osm_id: str, max_age_days: int = 14) -> dict | None:with _conn() as c:row = c.execute("""SELECT website, phone, email FROM enrich_cacheWHERE osm_id = ?AND fetched_at > datetime('now', ? || ' days')""", (osm_id, f"-{max_age_days}")).fetchone()return dict(row) if row else None21 unmodified lines""", (osm_id, name, address, biz_type, lat, lng, country,website, phone, email, status))c.commit()# Keep prospect_status table in syncprospect_set_status(osm_id, status)4 unmodified linesWHERE osm_id = ?""", (notes, osm_id))c.commit()def managed_set_status(osm_id: str, status: str):3 unmodified linesWHERE osm_id = ?""", (status, osm_id))c.commit()prospect_set_status(osm_id, status)def managed_delete(osm_id: str):1 unmodified linec.execute("DELETE FROM managed_prospects WHERE osm_id = ?", (osm_id,))c.execute("DELETE FROM prospect_status WHERE osm_id = ?", (osm_id,))c.commit()def managed_all() -> list[dict]:233 unmodified lines23423523623723823924010 unmodified lines25125225325425525625725825926026126226326421 unmodified lines2862872882892902912924 unmodified lines2972982993003013023033 unmodified lines3073083093103113123131 unmodified line315316317318319320321233 unmodified linesupdated_at = datetime('now')""", (osm_id, status))c.commit()db_backup.backup()def prospect_get_statuses(osm_ids: list) -> dict:10 unmodified lines# ── Enrich cache ──────────────────────────────────────────────────────────────def enrich_cache_get(osm_id: str, max_age_days: int = 14, country: str = "") -> dict | None:with _conn() as c:row = c.execute("""SELECT website, phone, email FROM enrich_cacheWHERE osm_id = ?AND (country = ? OR ? = '')AND fetched_at > datetime('now', ? || ' days')""", (osm_id, country, country, f"-{max_age_days}")).fetchone()return dict(row) if row else None21 unmodified lines""", (osm_id, name, address, biz_type, lat, lng, country,website, phone, email, status))c.commit()# Keep prospect_status in sync — backup handled inside prospect_set_statusprospect_set_status(osm_id, status)4 unmodified linesWHERE osm_id = ?""", (notes, osm_id))c.commit()db_backup.backup()def managed_set_status(osm_id: str, status: str):3 unmodified linesWHERE osm_id = ?""", (status, osm_id))c.commit()prospect_set_status(osm_id, status) # also backs updef managed_delete(osm_id: str):1 unmodified linec.execute("DELETE FROM managed_prospects WHERE osm_id = ?", (osm_id,))c.execute("DELETE FROM prospect_status WHERE osm_id = ?", (osm_id,))c.commit()db_backup.backup()def managed_all() -> list[dict]:
1037 unmodified lines10381039104010411042104310441045104610471048104910501037 unmodified linesreturn htmldef inject_language_switcher(html: str, current_code: str, all_codes: list[str]) -> str:"""Inject a fixed floating language switcher into HTML before </body>."""if len(all_codes) <= 1:return htmlcur = _LANG_META.get(current_code, {"flag": "🌐", "label": current_code.upper()})links = "".join(f'<a href="./{_LANG_META[c]["file"]}" style="display:flex;align-items:center;gap:.5rem;'f'padding:.6rem 1rem;text-decoration:none;color:#1a1a2e;font-size:.875rem;font-weight:500;" 'f'onmouseover="this.style.background=\'#f3f4f6\'" onmouseout="this.style.background=\'\'">'f'{_LANG_META[c]["flag"]} {_LANG_META[c]["label"]}</a>'1037 unmodified lines1038103910401041104210431044104510461047104810491050105110521037 unmodified linesreturn htmldef inject_language_switcher(html: str, current_code: str, all_codes: list[str], primary_code: str = "en") -> str:"""Inject a fixed floating language switcher into HTML before </body>."""if len(all_codes) <= 1:return htmlcur = _LANG_META.get(current_code, {"flag": "🌐", "label": current_code.upper()})def _file_for(c):return "index.html" if c == primary_code else f"index-{c}.html"links = "".join(f'<a href="./{_file_for(c)}" style="display:flex;align-items:center;gap:.5rem;'f'padding:.6rem 1rem;text-decoration:none;color:#1a1a2e;font-size:.875rem;font-weight:500;" 'f'onmouseover="this.style.background=\'#f3f4f6\'" onmouseout="this.style.background=\'\'">'f'{_LANG_META[c]["flag"]} {_LANG_META[c]["label"]}</a>'
47 unmodified lines4849505152538 unmodified lines62636465666768697011 unmodified lines82838485868788899039 unmodified lines1301311321331341351361371384 unmodified lines1431441451461471485 unmodified lines15415515615715815924 unmodified lines18418518618718818918 unmodified lines2082092102112122139 unmodified lines22322422522622722822923023121 unmodified lines25325425525625725825926026120 unmodified lines28228328428528628728828929029129226 unmodified lines31932032132232332432532632734 unmodified lines36236336436536636736836937037137237337437537668 unmodified lines44544644744844945047 unmodified lines.user-name { font-size:.82rem; font-weight:500; }.user-logout { font-size:.75rem; color:var(--muted); text-decoration:none; margin-left:4px; }.user-logout:hover { color:var(--red); }/* ── Page ── */.page { max-width:1200px; margin:0 auto; padding:36px 24px; }8 unmodified lines}.stat-card .num { font-size:1.8rem; font-weight:700; line-height:1; }.stat-card .lbl { font-size:.78rem; color:var(--muted); }.stat-card.green .num { color:var(--green); }.stat-card.yellow .num { color:var(--yellow); }.stat-card.red .num { color:var(--red); }/* ── Toolbar ── */.toolbar { display:flex; gap:12px; margin-bottom:20px; align-items:center; flex-wrap:wrap; }11 unmodified lines}.ftab:hover { color:var(--text); border-color:var(--text); }.ftab.active { background:var(--accent); border-color:var(--accent); color:#fff; }.ftab.ft-customer.active { background:rgba(74,222,128,.2); border-color:var(--green); color:var(--green); }.ftab.ft-pending.active { background:rgba(251,191,36,.2); border-color:var(--yellow); color:var(--yellow); }.ftab.ft-negative.active { background:rgba(248,113,113,.2); border-color:var(--red); color:var(--red); }.count-badge { font-size:.72rem; color:var(--muted); margin-left:auto; }/* ── Business rows ── */39 unmodified linesdisplay:inline-flex; align-items:center; gap:5px;padding:4px 10px; border-radius:99px; font-size:.75rem; font-weight:600;}.status-badge.st-customer { background:rgba(74,222,128,.15); color:var(--green); border:1px solid rgba(74,222,128,.3); }.status-badge.st-pending { background:rgba(251,191,36,.15); color:var(--yellow); border:1px solid rgba(251,191,36,.3); }.status-badge.st-negative { background:rgba(248,113,113,.15); color:var(--red); border:1px solid rgba(248,113,113,.3); }.status-badge.st-none { background:var(--surface2); color:var(--muted); border:1px solid var(--border); }.status-btns { display:flex; gap:4px; }4 unmodified lines}.stt-btn.stt-neg:hover, .stt-btn.stt-neg.active { background:rgba(248,113,113,.18); border-color:var(--red); color:var(--red); }.stt-btn.stt-pnd:hover, .stt-btn.stt-pnd.active { background:rgba(251,191,36,.18); border-color:var(--yellow); color:var(--yellow); }.stt-btn.stt-cust:hover, .stt-btn.stt-cust.active { background:rgba(74,222,128,.18); border-color:var(--green); color:var(--green); }.biz-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }5 unmodified lines}.btn-sm:hover { color:var(--text); border-color:var(--accent); }.btn-sm.danger:hover { color:var(--red); border-color:var(--red); }/* ── Empty ── */.empty-state {24 unmodified lines<a href="/businesses" class="nav-link accent active">📋 Businesses</a></nav><div class="topbar-sep"></div><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>18 unmodified lines<span class="num" id="statPending">—</span><span class="lbl">pending</span></div><div class="stat-card red"><span class="num" id="statNegative">—</span><span class="lbl">not interested</span>9 unmodified lines</div><div class="filter-tabs"><button class="ftab active" data-f="" onclick="setFilter(this,'')">All</button><button class="ftab ft-customer" data-f="customer" onclick="setFilter(this,'customer')">✓ Customers</button><button class="ftab ft-pending" data-f="pending" onclick="setFilter(this,'pending')">● Pending</button><button class="ftab ft-negative" data-f="negative" onclick="setFilter(this,'negative')">✕ Not interested</button></div><span class="count-badge" id="countBadge"></span></div>21 unmodified linesfunction bizIcon(t) { return TYPE_ICONS[(t||'').toLowerCase()] || '🏢'; }function statusLabel(s) {return {negative:'Not interested', pending:'Pending outreach', customer:'Customer'}[s] || 'Unset';}function statusIcon(s) { return {negative:'✕', pending:'●', customer:'✓'}[s] || '—'; }function esc(s) {return (s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');20 unmodified linesconst t = allBiz.length;const c = allBiz.filter(b => b.status === 'customer').length;const p = allBiz.filter(b => b.status === 'pending').length;const n = allBiz.filter(b => b.status === 'negative').length;document.getElementById('statTotal').textContent = t;document.getElementById('statCustomer').textContent = c;document.getElementById('statPending').textContent = p;document.getElementById('statNegative').textContent = n;}function render() {26 unmodified linesconst st = b.status || '';const stClass = st ? ' st-' + st : '';const negActive = st === 'negative' ? ' active' : '';const pndActive = st === 'pending' ? ' active' : '';const custActive = st === 'customer' ? ' active' : '';const contactItems = [b.website ? `<div class="biz-contact-item">🌐 <a href="${esc(b.website)}" target="_blank">${esc(b.website.replace(/^https?:\/\//,'').replace(/\/$/,''))}</a></div>` : '',34 unmodified lines<div style="font-size:.7rem;color:var(--muted);margin-top:4px;text-align:right">Updated ${timeAgo(b.updated_at)}</div></div><div class="status-btns"><button class="stt-btn stt-neg${negActive}" onclick="setStatus('${esc(b.osm_id)}','negative')" title="Not interested">✕</button><button class="stt-btn stt-pnd${pndActive}" onclick="setStatus('${esc(b.osm_id)}','pending')" title="Pending outreach">●</button><button class="stt-btn stt-cust${custActive}" onclick="setStatus('${esc(b.osm_id)}','customer')" title="Customer">✓</button></div><div class="biz-actions"><a href="/new?prefill=${prefill}" target="_blank" class="btn-sm">Generate Site →</a>${b.website ? `<a href="${esc(b.website)}" target="_blank" class="btn-sm">↗ Visit</a>` : ''}<button class="btn-sm danger" onclick="deleteBiz('${esc(b.osm_id)}','${esc(b.name)}')">✕ Remove</button></div></div></div>`;}68 unmodified lines'<div class="empty-state"><div class="icon">⚠️</div><p>Failed to load businesses.</p></div>';}})();</script></body></html>47 unmodified lines484950515253545556578 unmodified lines6667686970717273747511 unmodified lines8788899091929394959639 unmodified lines1361371381391401411421431441454 unmodified lines1501511521531541551565 unmodified lines16216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530624 unmodified lines33133233333433533633718 unmodified lines3563573583593603613623633643659 unmodified lines37537637737837938038138238338421 unmodified lines40640740840941041141241341420 unmodified lines43543643743843944044144244344444544644726 unmodified lines47447547647747847948048148248334 unmodified lines51851952052152252352452552652752852953053153253353453553653753853954054154254354468 unmodified lines613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100647 unmodified lines.user-name { font-size:.82rem; font-weight:500; }.user-logout { font-size:.75rem; color:var(--muted); text-decoration:none; margin-left:4px; }.user-logout:hover { color:var(--red); }.btn-restart { background:var(--surface2); border:1px solid var(--border); color:var(--muted); border-radius:8px; padding:6px 10px; font-size:1rem; cursor:pointer; transition:color .15s,background .15s; }.btn-restart:hover { color:var(--text); background:var(--surface3,#2a2a3a); }.btn-restart.spinning { animation:spin .7s linear infinite; color:var(--accent); }@keyframes spin { to { transform:rotate(360deg); } }/* ── Page ── */.page { max-width:1200px; margin:0 auto; padding:36px 24px; }8 unmodified lines}.stat-card .num { font-size:1.8rem; font-weight:700; line-height:1; }.stat-card .lbl { font-size:.78rem; color:var(--muted); }.stat-card.green .num { color:var(--green); }.stat-card.yellow .num { color:var(--yellow); }.stat-card.orange .num { color:#fb923c; }.stat-card.red .num { color:var(--red); }/* ── Toolbar ── */.toolbar { display:flex; gap:12px; margin-bottom:20px; align-items:center; flex-wrap:wrap; }11 unmodified lines}.ftab:hover { color:var(--text); border-color:var(--text); }.ftab.active { background:var(--accent); border-color:var(--accent); color:#fff; }.ftab.ft-customer.active { background:rgba(74,222,128,.2); border-color:var(--green); color:var(--green); }.ftab.ft-pending.active { background:rgba(251,191,36,.2); border-color:var(--yellow); color:var(--yellow); }.ftab.ft-interesting.active { background:rgba(251,146,60,.2); border-color:#fb923c; color:#fb923c; }.ftab.ft-negative.active { background:rgba(248,113,113,.2); border-color:var(--red); color:var(--red); }.count-badge { font-size:.72rem; color:var(--muted); margin-left:auto; }/* ── Business rows ── */39 unmodified linesdisplay:inline-flex; align-items:center; gap:5px;padding:4px 10px; border-radius:99px; font-size:.75rem; font-weight:600;}.status-badge.st-customer { background:rgba(74,222,128,.15); color:var(--green); border:1px solid rgba(74,222,128,.3); }.status-badge.st-pending { background:rgba(251,191,36,.15); color:var(--yellow); border:1px solid rgba(251,191,36,.3); }.status-badge.st-interesting { background:rgba(251,146,60,.15); color:#fb923c; border:1px solid rgba(251,146,60,.3); }.status-badge.st-negative { background:rgba(248,113,113,.15); color:var(--red); border:1px solid rgba(248,113,113,.3); }.status-badge.st-none { background:var(--surface2); color:var(--muted); border:1px solid var(--border); }.status-btns { display:flex; gap:4px; }4 unmodified lines}.stt-btn.stt-neg:hover, .stt-btn.stt-neg.active { background:rgba(248,113,113,.18); border-color:var(--red); color:var(--red); }.stt-btn.stt-pnd:hover, .stt-btn.stt-pnd.active { background:rgba(251,191,36,.18); border-color:var(--yellow); color:var(--yellow); }.stt-btn.stt-star:hover, .stt-btn.stt-star.active { background:rgba(251,146,60,.18); border-color:#fb923c; color:#fb923c; }.stt-btn.stt-cust:hover, .stt-btn.stt-cust.active { background:rgba(74,222,128,.18); border-color:var(--green); color:var(--green); }.biz-actions { display:flex; gap:6px; flex-wrap:wrap; justify-content:flex-end; }5 unmodified lines}.btn-sm:hover { color:var(--text); border-color:var(--accent); }.btn-sm.danger:hover { color:var(--red); border-color:var(--red); }.btn-demo-biz { color:#fb923c !important; border-color:#fb923c !important; }.btn-demo-biz:hover { background:rgba(251,146,60,.12) !important; }.btn-demo-biz:disabled { opacity:.4; cursor:not-allowed; }.demo-status-biz {font-size:.78rem; color:var(--muted); margin-top:6px;display:flex; flex-direction:column; gap:5px; align-items:flex-end;}.demo-status-biz a { color:var(--accent); text-decoration:none; font-weight:600; }.demo-progress-wrap { width:100%; height:4px; background:var(--surface2); border-radius:4px; overflow:hidden; }.demo-progress-bar { height:100%; background:#fb923c; border-radius:4px; transition:width .4s ease; }.demo-progress-row { display:flex; justify-content:space-between; align-items:center; width:100%; gap:8px; }.demo-progress-msg { color:var(--muted); font-size:.75rem; flex:1; text-align:left; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }.demo-progress-eta { color:var(--muted); font-size:.75rem; white-space:nowrap; opacity:.7; }.demo-copy { padding:3px 9px; background:var(--surface2); border:1px solid var(--border); border-radius:6px; color:var(--muted); font-size:.73rem; cursor:pointer; transition:color .15s,border-color .15s; }.demo-copy:hover { color:var(--accent); border-color:var(--accent); }.demo-clear { background:none; border:none; color:var(--muted); font-size:.8rem; cursor:pointer; padding:0 2px; line-height:1; opacity:.5; transition:opacity .15s,color .15s; }.demo-clear:hover { opacity:1; color:var(--red); }.btn-deploy { color:#38bdf8 !important; border-color:#38bdf8 !important; }.btn-deploy:hover { background:rgba(56,189,248,.12) !important; }.btn-deploy:disabled { opacity:.4; cursor:not-allowed; }.btn-sms { color:#4ade80 !important; border-color:#4ade80 !important; }.btn-sms:hover { background:rgba(74,222,128,.12) !important; }.btn-email { color:#a78bfa !important; border-color:#a78bfa !important; }.btn-email:hover { background:rgba(167,139,250,.12) !important; }/* ── SMS Modal ── */.sms-overlay {display:none; position:fixed; inset:0; background:rgba(0,0,0,.7);z-index:1000; align-items:center; justify-content:center;}.sms-overlay.open { display:flex; }.sms-phone {width:340px; max-width:94vw; background:#1c1c1e; border-radius:40px;box-shadow:0 24px 64px rgba(0,0,0,.7); overflow:hidden; display:flex; flex-direction:column;font-family:-apple-system,'SF Pro Text',system-ui,sans-serif;}.sms-topbar {background:#2c2c2e; padding:14px 20px 10px;display:flex; align-items:center; justify-content:space-between;}.sms-topbar-left { display:flex; align-items:center; gap:8px; }.sms-back { background:none; border:none; color:#0a84ff; font-size:.9rem; cursor:pointer; padding:0; }.sms-contact-avatar {width:36px; height:36px; border-radius:50%; background:#3a3a3c;display:grid; place-items:center; font-size:.9rem;}.sms-contact-name { font-size:.85rem; font-weight:600; color:#fff; }.sms-contact-sub { font-size:.7rem; color:#8e8e93; }.sms-topbar-close { background:none; border:none; color:#8e8e93; font-size:1.1rem; cursor:pointer; }.sms-chat {flex:1; background:#000; padding:16px 14px; min-height:200px;max-height:320px; overflow-y:auto; display:flex; flex-direction:column; gap:8px;}.sms-bubble-wrap { display:flex; justify-content:flex-end; }.sms-bubble {background:#0a84ff; color:#fff; border-radius:18px 18px 4px 18px;padding:10px 14px; font-size:.82rem; line-height:1.55; max-width:85%;white-space:pre-wrap; word-break:break-word;}.sms-edit-area {background:#1c1c1e; padding:12px 14px; border-top:1px solid #2c2c2e;display:flex; flex-direction:column; gap:8px;}.sms-textarea {width:100%; background:#2c2c2e; border:none; border-radius:12px;color:#fff; font-size:.82rem; line-height:1.55; padding:10px 13px;resize:none; min-height:90px; outline:none; font-family:inherit;}.sms-actions { display:flex; gap:8px; justify-content:flex-end; }.sms-btn-copy {padding:8px 18px; background:#0a84ff; border:none; border-radius:20px;color:#fff; font-size:.8rem; font-weight:600; cursor:pointer; transition:opacity .15s;}.sms-btn-copy:hover { opacity:.85; }.sms-btn-whatsapp {padding:8px 18px; background:#25d366; border:none; border-radius:20px;color:#fff; font-size:.8rem; font-weight:600; cursor:pointer; transition:opacity .15s;}.sms-btn-whatsapp:hover { opacity:.85; }.sms-lang-row { display:flex; gap:6px; }.sms-lang-btn {flex:1; padding:6px 10px; background:#2c2c2e; border:1px solid #3a3a3c;border-radius:10px; color:#8e8e93; font-size:.78rem; cursor:pointer; transition:all .15s;}.sms-lang-btn.active { background:#0a84ff; border-color:#0a84ff; color:#fff; font-weight:600; }.sms-lang-btn:not(.active):hover { background:#3a3a3c; color:#fff; }/* ── Email Modal ── */.email-overlay {display:none; position:fixed; inset:0; background:rgba(0,0,0,.7);z-index:1000; align-items:center; justify-content:center;}.email-overlay.open { display:flex; }.email-card {width:420px; max-width:95vw; background:var(--surface); border:1px solid var(--border);border-radius:16px; box-shadow:0 24px 64px rgba(0,0,0,.5); overflow:hidden;display:flex; flex-direction:column;}.email-topbar {background:var(--surface2); padding:14px 18px;display:flex; align-items:center; justify-content:space-between;border-bottom:1px solid var(--border);}.email-topbar-left { display:flex; align-items:center; gap:10px; }.email-contact-avatar {width:34px; height:34px; border-radius:50%; background:var(--accent);display:grid; place-items:center; font-size:.85rem; font-weight:700; color:#fff;}.email-contact-name { font-size:.88rem; font-weight:600; color:var(--text); }.email-contact-sub { font-size:.72rem; color:var(--muted); }.email-topbar-close { background:none; border:none; color:var(--muted); font-size:1.1rem; cursor:pointer; }.email-body-area { padding:16px 18px; display:flex; flex-direction:column; gap:10px; }.email-lang-row { display:flex; gap:6px; }.email-lang-btn {flex:1; padding:6px 10px; background:var(--surface2); border:1px solid var(--border);border-radius:8px; color:var(--muted); font-size:.78rem; cursor:pointer; transition:all .15s;}.email-lang-btn.active { background:var(--accent); border-color:var(--accent); color:#fff; font-weight:600; }.email-lang-btn:not(.active):hover { color:var(--text); border-color:var(--accent); }.email-field { display:flex; flex-direction:column; gap:4px; }.email-label { font-size:.72rem; color:var(--muted); font-weight:500; }.email-input {background:var(--surface2); border:1px solid var(--border); border-radius:8px;color:var(--text); font-size:.82rem; padding:8px 12px; outline:none;font-family:inherit; transition:border-color .15s;}.email-input:focus { border-color:var(--accent); }.email-textarea { resize:none; min-height:130px; line-height:1.55; }.email-actions { display:flex; gap:8px; justify-content:flex-end; padding:0 18px 16px; }.email-btn-send {padding:9px 22px; background:var(--accent); border:none; border-radius:20px;color:#fff; font-size:.82rem; font-weight:600; cursor:pointer; transition:opacity .15s;}.email-btn-send:hover { opacity:.85; }.email-btn-copy {padding:9px 16px; background:var(--surface2); border:1px solid var(--border);border-radius:20px; color:var(--muted); font-size:.82rem; cursor:pointer; transition:all .15s;}.email-btn-copy:hover { color:var(--text); border-color:var(--accent); }/* ── Empty ── */.empty-state {24 unmodified lines<a href="/businesses" class="nav-link accent active">📋 Businesses</a></nav><div class="topbar-sep"></div><button class="btn-restart" onclick="restartApp(this)" title="Restart server">↺</button><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>18 unmodified lines<span class="num" id="statPending">—</span><span class="lbl">pending</span></div><div class="stat-card orange"><span class="num" id="statInteresting">—</span><span class="lbl">interesting</span></div><div class="stat-card red"><span class="num" id="statNegative">—</span><span class="lbl">not interested</span>9 unmodified lines</div><div class="filter-tabs"><button class="ftab active" data-f="" onclick="setFilter(this,'')">All</button><button class="ftab ft-customer" data-f="customer" onclick="setFilter(this,'customer')">✓ Customers</button><button class="ftab ft-pending" data-f="pending" onclick="setFilter(this,'pending')">● Pending</button><button class="ftab ft-interesting" data-f="interesting" onclick="setFilter(this,'interesting')">★ Interesting</button><button class="ftab ft-negative" data-f="negative" onclick="setFilter(this,'negative')">✕ Not interested</button></div><span class="count-badge" id="countBadge"></span></div>21 unmodified linesfunction bizIcon(t) { return TYPE_ICONS[(t||'').toLowerCase()] || '🏢'; }function statusLabel(s) {return {negative:'Not interested', pending:'Pending outreach', interesting:'Interesting', customer:'Customer'}[s] || 'Unset';}function statusIcon(s) { return {negative:'✕', pending:'●', interesting:'★', customer:'✓'}[s] || '—'; }function esc(s) {return (s||'').replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');20 unmodified linesconst t = allBiz.length;const c = allBiz.filter(b => b.status === 'customer').length;const p = allBiz.filter(b => b.status === 'pending').length;const x = allBiz.filter(b => b.status === 'interesting').length;const n = allBiz.filter(b => b.status === 'negative').length;document.getElementById('statTotal').textContent = t;document.getElementById('statCustomer').textContent = c;document.getElementById('statPending').textContent = p;document.getElementById('statInteresting').textContent = x;document.getElementById('statNegative').textContent = n;}function render() {26 unmodified linesconst st = b.status || '';const stClass = st ? ' st-' + st : '';const negActive = st === 'negative' ? ' active' : '';const pndActive = st === 'pending' ? ' active' : '';const starActive = st === 'interesting' ? ' active' : '';const custActive = st === 'customer' ? ' active' : '';const contactItems = [b.website ? `<div class="biz-contact-item">🌐 <a href="${esc(b.website)}" target="_blank">${esc(b.website.replace(/^https?:\/\//,'').replace(/\/$/,''))}</a></div>` : '',34 unmodified lines<div style="font-size:.7rem;color:var(--muted);margin-top:4px;text-align:right">Updated ${timeAgo(b.updated_at)}</div></div><div class="status-btns"><button class="stt-btn stt-neg${negActive}" onclick="setStatus('${esc(b.osm_id)}','negative')" title="Not interested">✕</button><button class="stt-btn stt-pnd${pndActive}" onclick="setStatus('${esc(b.osm_id)}','pending')" title="Pending outreach">●</button><button class="stt-btn stt-star${starActive}" onclick="setStatus('${esc(b.osm_id)}','interesting')" title="Interesting">★</button><button class="stt-btn stt-cust${custActive}" onclick="setStatus('${esc(b.osm_id)}','customer')" title="Customer">✓</button></div><div class="biz-actions"><a href="/new?prefill=${prefill}" target="_blank" class="btn-sm">Customize →</a><button class="btn-sm btn-demo-biz" id="demo-btn-${esc(b.osm_id)}" onclick="quickDemo('${esc(b.osm_id)}')" ${localStorage.getItem('demo_'+b.osm_id) ? 'style="display:none"' : ''}>⚡ Quick Demo</button><button class="btn-sm btn-deploy" id="deploy-btn-${esc(b.osm_id)}" onclick="deployDemo('${esc(b.osm_id)}')" ${localStorage.getItem('demo_'+b.osm_id) && !localStorage.getItem('deployed_'+b.osm_id) ? '' : 'style="display:none"'}>🚀 Deploy</button><button class="btn-sm btn-sms" id="sms-btn-${esc(b.osm_id)}" onclick="openSMS('${esc(b.osm_id)}')" ${localStorage.getItem('deployed_'+b.osm_id) ? '' : 'style="display:none"'}>📱 SMS</button><button class="btn-sm btn-email" id="email-btn-${esc(b.osm_id)}" onclick="openEmail('${esc(b.osm_id)}')" ${localStorage.getItem('deployed_'+b.osm_id) ? '' : 'style="display:none"'}>✉ Email</button>${b.website ? `<a href="${esc(b.website)}" target="_blank" class="btn-sm">↗ Visit</a>` : ''}<button class="btn-sm danger" onclick="deleteBiz('${esc(b.osm_id)}','${esc(b.name)}')">✕ Remove</button></div><div class="demo-status-biz" id="demo-status-${esc(b.osm_id)}" ${localStorage.getItem('demo_'+b.osm_id) ? `style="display:flex"` : `style="display:none"`}>${localStorage.getItem('deployed_'+b.osm_id)? `<a href="${localStorage.getItem('deployed_'+b.osm_id)}" target="_blank">🌐 Live: ${(localStorage.getItem('deployed_'+b.osm_id)||'').replace('https://','')}</a><button class="demo-clear" onclick="clearDeploy('${esc(b.osm_id)}')" title="Remove">✕</button>`: localStorage.getItem('demo_'+b.osm_id)? `<a href="${localStorage.getItem('demo_'+b.osm_id)}" target="_blank">View demo ↗</a><button class="demo-clear" onclick="clearDemo('${esc(b.osm_id)}')" title="Remove demo link">✕</button>`: ''}</div></div></div>`;}68 unmodified lines'<div class="empty-state"><div class="icon">⚠️</div><p>Failed to load businesses.</p></div>';}})();function clearDemo(osm_id) {localStorage.removeItem('demo_' + osm_id);localStorage.removeItem('deployed_' + osm_id);const statusEl = document.getElementById(`demo-status-${osm_id}`);const demoBtn = document.getElementById(`demo-btn-${osm_id}`);const deployBtn = document.getElementById(`deploy-btn-${osm_id}`);const smsBtn = document.getElementById(`sms-btn-${osm_id}`);const emailBtn = document.getElementById(`email-btn-${osm_id}`);if (statusEl) { statusEl.style.display = 'none'; statusEl.innerHTML = ''; }if (demoBtn) { demoBtn.style.display = ''; demoBtn.disabled = false; demoBtn.textContent = '⚡ Quick Demo'; }if (deployBtn) deployBtn.style.display = 'none';if (smsBtn) smsBtn.style.display = 'none';if (emailBtn) emailBtn.style.display = 'none';}function clearDeploy(osm_id) {localStorage.removeItem('deployed_' + osm_id);const statusEl = document.getElementById(`demo-status-${osm_id}`);const smsBtn = document.getElementById(`sms-btn-${osm_id}`);const emailBtn = document.getElementById(`email-btn-${osm_id}`);const deployBtn = document.getElementById(`deploy-btn-${osm_id}`);const previewUrl = localStorage.getItem('demo_' + osm_id);if (smsBtn) smsBtn.style.display = 'none';if (emailBtn) emailBtn.style.display = 'none';if (deployBtn) deployBtn.style.display = previewUrl ? '' : 'none';if (statusEl && previewUrl) {statusEl.innerHTML = `<a href="${previewUrl}" target="_blank">View demo ↗</a><button class="demo-clear" onclick="clearDemo('${osm_id}')" title="Remove demo link">✕</button>`;}}async function quickDemo(osm_id) {const b = allBiz.find(b => b.osm_id === osm_id);if (!b) return;const btn = document.getElementById(`demo-btn-${osm_id}`);const statusEl = document.getElementById(`demo-status-${osm_id}`);btn.disabled = true;btn.textContent = '⏳ Generating…';statusEl.style.display = 'flex';statusEl.innerHTML = `<div class="demo-progress-row"><span class="demo-progress-msg">Starting…</span><span class="demo-progress-eta"></span></div><div class="demo-progress-wrap"><div class="demo-progress-bar" id="dpbar-${osm_id}" style="width:2%"></div></div>`;const STEPS = [{ match: 'Building business profile', pct: 5 },{ match: 'Generating website', pct: 15 },{ match: 'may take', pct: 20 },{ match: 'Site generated', pct: 65 },{ match: 'Translating to', pct: 75 },{ match: 'Translation done', pct: 87 },{ match: 'language switcher', pct: 93 },{ match: 'Done', pct: 100},];const msgEl = () => statusEl.querySelector('.demo-progress-msg');const etaEl = () => statusEl.querySelector('.demo-progress-eta');const barEl = () => document.getElementById(`dpbar-${osm_id}`);const startMs = Date.now();let currentPct = 2;function setProgress(pct, msg) {currentPct = Math.max(currentPct, pct);if (barEl()) barEl().style.width = currentPct + '%';if (msg && msgEl()) msgEl().textContent = msg;const elapsed = (Date.now() - startMs) / 1000;if (currentPct > 5 && currentPct < 100 && etaEl()) {const estTotal = elapsed / (currentPct / 100);const left = Math.max(1, Math.round(estTotal - elapsed));etaEl().textContent = `~${left}s left`;}}const city = (b.address || '').split(',').pop().trim();const form = {name: b.name, type: b.biz_type || 'restaurant',address: b.address || '', phone: b.phone || '',email: b.email || '', city,site_language: 'Finnish',translation_languages: ['English (UK)'],deploy_github: false, deploy_cloudflare: false,};let job_id;try {const r = await fetch('/generate', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(form) });const data = await r.json();if (!r.ok) throw new Error(data.error || 'Generate failed');job_id = data.job_id;} catch(e) {statusEl.innerHTML = `<span style="color:var(--red)">❌ ${e.message}</span>`;btn.disabled = false; btn.textContent = '⚡ Quick Demo';return;}const poll = async () => {try {const r = await fetch(`/status/${job_id}`);const job = await r.json();const logs = job.log || [];const lastMsg = logs.slice(-1)[0] || '';// map latest log to progressfor (const step of [...STEPS].reverse()) {if (lastMsg.includes(step.match)) { setProgress(step.pct, lastMsg); break; }}if (job.status === 'done' && job.result?.slug) {setProgress(100, 'Done!');if (etaEl()) etaEl().textContent = '';const slug = job.result.slug;const previewUrl = `${location.origin}/preview/${slug}/index.html`;localStorage.setItem('demo_' + osm_id, previewUrl);btn.style.display = 'none';const deployBtn = document.getElementById(`deploy-btn-${osm_id}`);if (deployBtn) deployBtn.style.display = '';setTimeout(() => {statusEl.innerHTML = `<a href="${previewUrl}" target="_blank">View demo ↗</a><button class="demo-clear" onclick="clearDemo('${osm_id}')" title="Remove demo link">✕</button>`;}, 500);} else if (job.status === 'error') {statusEl.innerHTML = `<span style="color:var(--red)">❌ ${job.error || 'Generation failed'}</span>`;btn.disabled = false; btn.textContent = '⚡ Quick Demo';} else {setTimeout(poll, 1500);}} catch { setTimeout(poll, 2000); }};setTimeout(poll, 1500);}async function deployDemo(osm_id) {const deployBtn = document.getElementById(`deploy-btn-${osm_id}`);const statusEl = document.getElementById(`demo-status-${osm_id}`);deployBtn.disabled = true;deployBtn.textContent = '⏳ Deploying…';statusEl.style.display = 'flex';statusEl.innerHTML = `<div class="demo-progress-row"><span class="demo-progress-msg">Connecting to Cloudflare…</span><span class="demo-progress-eta"></span></div><div class="demo-progress-wrap"><div class="demo-progress-bar" id="dpbar2-${osm_id}" style="width:5%;background:#38bdf8"></div></div>`;const msgEl = () => statusEl.querySelector('.demo-progress-msg');const barEl = () => document.getElementById(`dpbar2-${osm_id}`);let job_id;try {const r = await fetch(`/api/deploy-demo/${osm_id}`, { method:'POST' });const data = await r.json();if (!r.ok) throw new Error(data.error || 'Deploy failed');job_id = data.job_id;} catch(e) {statusEl.innerHTML = `<span style="color:var(--red)">❌ ${e.message}</span>`;deployBtn.disabled = false; deployBtn.textContent = '🚀 Deploy';return;}const DEPLOY_STEPS = [{ match: 'Deploying', pct: 10 },{ match: 'Uploading', pct: 40 },{ match: 'Live →', pct: 90 },{ match: 'Done', pct: 100 },];const poll = async () => {try {const r = await fetch(`/status/${job_id}`);const job = await r.json();const lastMsg = (job.log || []).slice(-1)[0] || '';for (const step of [...DEPLOY_STEPS].reverse()) {if (lastMsg.includes(step.match)) {if (barEl()) barEl().style.width = step.pct + '%';if (msgEl()) msgEl().textContent = lastMsg;break;}}if (job.status === 'done') {const liveUrl = job.result?.live_url || '';if (liveUrl) {localStorage.setItem('deployed_' + osm_id, liveUrl);deployBtn.style.display = 'none';const smsBtn = document.getElementById(`sms-btn-${osm_id}`);if (smsBtn) smsBtn.style.display = '';const emailBtn = document.getElementById(`email-btn-${osm_id}`);if (emailBtn) emailBtn.style.display = '';const domain = liveUrl.replace('https://','');statusEl.innerHTML = `<a href="${liveUrl}" target="_blank">🌐 Live: ${domain}</a><button class="demo-clear" onclick="clearDeploy('${osm_id}')" title="Remove">✕</button>`;} else {statusEl.innerHTML = `<span style="color:var(--red)">⚠️ Deploy done but no URL returned</span>`;deployBtn.disabled = false; deployBtn.textContent = '🚀 Deploy';}} else if (job.status === 'error') {statusEl.innerHTML = `<span style="color:var(--red)">❌ ${job.error || 'Deploy failed'}</span>`;deployBtn.disabled = false; deployBtn.textContent = '🚀 Deploy';} else {setTimeout(poll, 1500);}} catch { setTimeout(poll, 2000); }};setTimeout(poll, 1500);}const SMS_TEMPLATES = {fi: (name, domain) =>`Hei,\n\nTein teille esimerkkisivuston - halusin näyttää, miltä ${name} voisi näyttää verkossa.\n\nVoitte katsoa sen täältä:\n${domain}\n(Kopioi osoite selaimeesi)\n\nOtetaan yhteyttä jos kiinnostaa.\n\nTerveisin,\nEdward`,en: (name, domain) =>`Hi,\n\nI put together a demo website for ${name} - wanted to show what it could look like online.\n\nYou can view it here:\n${domain}\n(Copy the address into your browser)\n\nFeel free to reach out if you're interested.\n\nBest regards,\nEdward`,};let _smsCurrentOsmId = null;const EMAIL_TEMPLATES = {fi: (name, domain) => ({subject: `Esimerkkisivu - ${name}`,body: `Hei,\n\nTein teille esimerkkisivuston - halusin näyttää, miltä ${name} voisi näyttää verkossa.\n\nVoitte katsoa sen täältä:\n${domain}\n(Kopioi osoite selaimeesi)\n\nOtetaan yhteyttä jos kiinnostaa.\n\nTerveisin,\nEdward`,}),en: (name, domain) => ({subject: `Demo website - ${name}`,body: `Hi,\n\nI put together a demo website for ${name} - wanted to show what it could look like online.\n\nYou can view it here:\n${domain}\n(Copy the address into your browser)\n\nFeel free to reach out if you're interested.\n\nBest regards,\nEdward`,}),};let _emailCurrentOsmId = null;function openEmail(osm_id) {const b = allBiz.find(b => b.osm_id === osm_id);if (!b) return;_emailCurrentOsmId = osm_id;const liveUrl = localStorage.getItem('deployed_' + osm_id) || '';const domain = liveUrl.replace('https://','').replace(/\/$/,'');document.getElementById('email-modal-name').textContent = b.name;document.getElementById('email-modal-init').textContent = b.name.charAt(0).toUpperCase();setEmailLang('fi', b.name, domain);document.getElementById('email-modal').classList.add('open');}function setEmailLang(lang, name, domain) {if (!name) name = document.getElementById('email-modal-name').textContent;if (!domain && _emailCurrentOsmId) {const liveUrl = localStorage.getItem('deployed_' + _emailCurrentOsmId) || '';domain = liveUrl.replace('https://','').replace(/\/$/,'');}const tpl = EMAIL_TEMPLATES[lang](name, domain);document.getElementById('email-subject').value = tpl.subject;document.getElementById('email-body').value = tpl.body;document.querySelectorAll('.email-lang-btn').forEach(b => b.classList.remove('active'));document.getElementById(`email-lang-${lang}`)?.classList.add('active');}function sendEmail() {const b = _emailCurrentOsmId ? allBiz.find(x => x.osm_id === _emailCurrentOsmId) : null;const to = b?.email || '';const subject = document.getElementById('email-subject').value;const body = document.getElementById('email-body').value;window.open(`mailto:${to}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`, '_blank');}function openSMS(osm_id) {const b = allBiz.find(b => b.osm_id === osm_id);if (!b) return;_smsCurrentOsmId = osm_id;const liveUrl = localStorage.getItem('deployed_' + osm_id) || '';const domain = liveUrl.replace('https://','').replace(/\/$/,'');const phone = (b.phone || '').replace(/\s/g,'');const name = b.name || '';document.getElementById('sms-modal-name').textContent = name;document.getElementById('sms-modal-init').textContent = name.charAt(0).toUpperCase();// set active language to Finnish by defaultsetSMSLang('fi', name, domain);const waBtn = document.getElementById('sms-wa-btn');if (phone) {const waNum = phone.startsWith('+') ? phone.slice(1) : '358' + phone.replace(/^0/,'');const ta = document.getElementById('sms-textarea');waBtn.onclick = () => window.open(`https://wa.me/${waNum}?text=${encodeURIComponent(ta.value)}`, '_blank');waBtn.style.display = '';} else {waBtn.style.display = 'none';}document.getElementById('sms-modal').classList.add('open');}function setSMSLang(lang, name, domain) {// resolve name/domain from current modal state if not passedif (!name) name = document.getElementById('sms-modal-name').textContent;if (!domain && _smsCurrentOsmId) {const liveUrl = localStorage.getItem('deployed_' + _smsCurrentOsmId) || '';domain = liveUrl.replace('https://','').replace(/\/$/,'');}const ta = document.getElementById('sms-textarea');ta.value = SMS_TEMPLATES[lang](name, domain);syncBubble();document.querySelectorAll('.sms-lang-btn').forEach(b => b.classList.remove('active'));document.getElementById(`sms-lang-${lang}`)?.classList.add('active');}function syncBubble() {const ta = document.getElementById('sms-textarea');const bubble = document.getElementById('sms-bubble-text');if (bubble) bubble.textContent = ta.value;}async function restartApp(btn) {btn.classList.add('spinning');btn.disabled = true;await fetch('/api/restart', { method: 'POST' }).catch(() => {});const deadline = Date.now() + 30000;const ping = () => {if (Date.now() > deadline) {btn.classList.remove('spinning');btn.disabled = false;btn.title = 'Restart failed — check server logs';return;}fetch('/').then(() => location.reload()).catch(() => setTimeout(ping, 700));};setTimeout(ping, 1500);}</script><!-- SMS Modal --><div class="sms-overlay" id="sms-modal" onclick="if(event.target===this)this.classList.remove('open')"><div class="sms-phone"><div class="sms-topbar"><div class="sms-topbar-left"><button class="sms-back" onclick="document.getElementById('sms-modal').classList.remove('open')">‹ Back</button><div class="sms-contact-avatar" id="sms-modal-init">?</div><div><div class="sms-contact-name" id="sms-modal-name">Business</div><div class="sms-contact-sub">SMS</div></div></div><button class="sms-topbar-close" onclick="document.getElementById('sms-modal').classList.remove('open')">✕</button></div><div class="sms-chat"><div class="sms-bubble-wrap"><div class="sms-bubble" id="sms-bubble-text"></div></div></div><div class="sms-edit-area"><div class="sms-lang-row"><button class="sms-lang-btn active" id="sms-lang-fi" onclick="setSMSLang('fi')">🇫🇮 Suomi</button><button class="sms-lang-btn" id="sms-lang-en" onclick="setSMSLang('en')">🇬🇧 English</button></div><textarea class="sms-textarea" id="sms-textarea" oninput="syncBubble()" rows="5"></textarea><div class="sms-actions"><button class="sms-btn-whatsapp" id="sms-wa-btn">WhatsApp ↗</button><button class="sms-btn-copy" onclick="navigator.clipboard.writeText(document.getElementById('sms-textarea').value).then(()=>{this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)})">Copy</button></div></div></div></div><!-- Email Modal --><div class="email-overlay" id="email-modal" onclick="if(event.target===this)this.classList.remove('open')"><div class="email-card"><div class="email-topbar"><div class="email-topbar-left"><div class="email-contact-avatar" id="email-modal-init">?</div><div><div class="email-contact-name" id="email-modal-name">Business</div><div class="email-contact-sub">Email</div></div></div><button class="email-topbar-close" onclick="document.getElementById('email-modal').classList.remove('open')">✕</button></div><div class="email-body-area"><div class="email-lang-row"><button class="email-lang-btn active" id="email-lang-fi" onclick="setEmailLang('fi')">🇫🇮 Suomi</button><button class="email-lang-btn" id="email-lang-en" onclick="setEmailLang('en')">🇬🇧 English</button></div><div class="email-field"><span class="email-label">Subject</span><input class="email-input" id="email-subject" type="text"></div><div class="email-field"><span class="email-label">Message</span><textarea class="email-input email-textarea" id="email-body" rows="7"></textarea></div></div><div class="email-actions"><button class="email-btn-copy" onclick="navigator.clipboard.writeText(document.getElementById('email-body').value).then(()=>{this.textContent='Copied!';setTimeout(()=>this.textContent='Copy',1500)})">Copy</button><button class="email-btn-send" onclick="sendEmail()">Open in Gmail ↗</button></div></div></div></body></html>
677 unmodified lines67867968068168268336 unmodified lines720721722723724725645 unmodified lines137113721373137413751376677 unmodified lineswhite-space: nowrap;}.user-logout:hover { color: var(--red); border-color: var(--red); }@media (max-width: 640px) {.page { padding: 20px 16px 48px; }36 unmodified lines<span class="token-reset" id="cerebrasReset"></span></div></div><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>645 unmodified linesif (btn) { const orig = btn.textContent; btn.textContent = '✓ Copied!'; setTimeout(() => btn.textContent = orig, 1500); }});}</script></body></html>677 unmodified lines67867968068168268368468568668736 unmodified lines724725726727728729730645 unmodified lines13761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398677 unmodified lineswhite-space: nowrap;}.user-logout:hover { color: var(--red); border-color: var(--red); }.btn-restart { background: var(--surface2); border: 1px solid var(--border); color: var(--muted); border-radius: 8px; padding: 6px 10px; font-size: 1rem; cursor: pointer; transition: color .15s, background .15s; }.btn-restart:hover { color: var(--text); background: var(--surface3, #2a2a3a); }.btn-restart.spinning { animation: spin .7s linear infinite; color: var(--accent); }@keyframes spin { to { transform: rotate(360deg); } }@media (max-width: 640px) {.page { padding: 20px 16px 48px; }36 unmodified lines<span class="token-reset" id="cerebrasReset"></span></div></div><button class="btn-restart" onclick="restartApp(this)" title="Restart server">↺</button><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>645 unmodified linesif (btn) { const orig = btn.textContent; btn.textContent = '✓ Copied!'; setTimeout(() => btn.textContent = orig, 1500); }});}async function restartApp(btn) {btn.classList.add('spinning');btn.disabled = true;await fetch('/api/restart', { method: 'POST' }).catch(() => {});const deadline = Date.now() + 30000;const ping = () => {if (Date.now() > deadline) {btn.classList.remove('spinning');btn.disabled = false;btn.title = 'Restart failed — check server logs';return;}fetch('/').then(() => location.reload()).catch(() => setTimeout(ping, 700));};setTimeout(ping, 1500);}</script></body></html>
30 unmodified lines31323334353699 unmodified lines13613713813914014144 unmodified lines18618718818919019110 unmodified lines2022032042052062073 unmodified lines21121221321421521623 unmodified lines24024124224324424548 unmodified lines29429529629729829965 unmodified lines365366367368369370206 unmodified lines5775785795805815825835845855865875885895905915 unmodified lines597598599600601602603604120 unmodified lines7257267277287297307317327 unmodified lines74074174274374474574674774874975075175275375413 unmodified lines7687697707717727737747757767777787797807817827837841 unmodified line78678778878979079114 unmodified lines80680780880981081181281381481540 unmodified lines85685785885986086186286386486586686786886987087187287387487530 unmodified lines.user-name { font-size:.82rem; font-weight:500; }.user-logout { font-size:.78rem; color:var(--muted); text-decoration:none; padding:4px 10px; border-radius:6px; border:1px solid var(--border); transition:color .12s,border-color .12s; white-space:nowrap; }.user-logout:hover { color:var(--red); border-color:var(--red); }/* page */.page { max-width:1280px; margin:0 auto; padding:32px 32px 64px; }99 unmodified lines}.section-count.red { background:rgba(248,113,113,.15); color:var(--red); border:1px solid rgba(248,113,113,.3); }.section-count.green { background:rgba(74,222,128,.15); color:var(--green); border:1px solid rgba(74,222,128,.3); }.section-chevron { margin-left:auto; color:var(--muted); font-size:.75rem; transition:transform .2s; }.section-chevron.open { transform:rotate(180deg); }44 unmodified lines}.btn-autofill:hover { color:var(--yellow); border-color:var(--yellow); }.btn-autofill:disabled { opacity:.4; cursor:not-allowed; }/* status buttons */.status-row {10 unmodified lines.stt-btn.stt-neg:hover, .stt-btn.stt-neg.active { background:rgba(248,113,113,.18); border-color:var(--red); color:var(--red); }.stt-btn.stt-pnd:hover, .stt-btn.stt-pnd.active { background:rgba(251,191,36,.18); border-color:var(--yellow); color:var(--yellow); }.stt-btn.stt-cust:hover, .stt-btn.stt-cust.active { background:rgba(74,222,128,.18); border-color:var(--green); color:var(--green); }.status-hint { font-size:.7rem; color:var(--muted); margin-left:4px; }/* card border per status */3 unmodified lines.prospect-card.st-pending:hover { border-color:var(--yellow); }.prospect-card.st-customer { border-color:rgba(74,222,128,.55); }.prospect-card.st-customer:hover { border-color:var(--green); }/* no-results */.empty-state {23 unmodified lines<a href="/businesses" class="nav-link accent">📋 Businesses</a></nav><div class="topbar-sep"></div><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>48 unmodified lines</button></div><!-- Search + enrich progress --><div class="search-progress" id="searchProgress"><div class="progress-track">65 unmodified lines</div></div><!-- Not interested group (shown when first negative set) --><div id="negativeSectionWrap" style="display:none"><div class="section-head" onclick="toggleSection('negativeSection', this)" style="margin-top:28px">206 unmodified linesdocument.getElementById('statNoSite').textContent = noSite;document.getElementById('statHasSite').textContent = hasSite;// section counts (exclude customer/negative from main sections)const inNoSite = ps.filter(p => !p.has_website && p.status !== 'customer' && p.status !== 'negative').length;const inHasSite = ps.filter(p => p.has_website && p.status !== 'customer' && p.status !== 'negative').length;const inCustomer = ps.filter(p => p.status === 'customer').length;const inNegative = ps.filter(p => p.status === 'negative').length;document.getElementById('noSiteCount').textContent = inNoSite;document.getElementById('hasSiteCount').textContent = inHasSite;document.getElementById('customerCount').textContent = inCustomer;document.getElementById('negativeCount').textContent = inNegative;}function renderResults(data) {5 unmodified linesdocument.getElementById('noSiteGrid').innerHTML = noSite.map(p => renderCard(p, window._prospects.indexOf(p))).join('');document.getElementById('hasSiteGrid').innerHTML = hasSite.map(p => renderCard(p, window._prospects.indexOf(p))).join('');document.getElementById('customerGrid').innerHTML = '';document.getElementById('negativeGrid').innerHTML = '';document.getElementById('customerSectionWrap').style.display = 'none';document.getElementById('negativeSectionWrap').style.display = 'none';updateSummaryBar();120 unmodified lines}}function statusLabel(s) {return {negative:'Not interested', pending:'Pending', customer:'Customer'}[s] || '';}// ── CRM status ─────────────────────────────────────────────────────────────7 unmodified linesif (!card) return;// update border classcard.classList.remove('st-negative','st-pending','st-customer');if (newStatus) card.classList.add('st-' + newStatus);// update button active state + hint textcard.querySelectorAll('.stt-btn').forEach(b => b.classList.remove('active'));const btnMap = {negative:'stt-neg', pending:'stt-pnd', customer:'stt-cust'};if (newStatus) card.querySelector('.' + btnMap[newStatus])?.classList.add('active');const hint = card.querySelector('.status-hint');const labels = {negative:'Not interested', pending:'Pending', customer:'Customer'};if (hint) { hint.textContent = labels[newStatus] || ''; }else if (newStatus) {const h = document.createElement('span');13 unmodified lineslat: p.lat, lng: p.lng, country: p.country_code,website: p.website || '', phone: p.phone || '', email: p.email || '',}),});}function moveCardToSection(idx, p) {const card = document.getElementById(`pcard-${idx}`);if (!card) return;const targetId = p.status === 'customer' ? 'customerGrid': p.status === 'negative' ? 'negativeGrid': p.has_website ? 'hasSiteGrid': 'noSiteGrid';document.getElementById(targetId).prepend(card);if (p.status === 'customer') {1 unmodified linewrap.style.display = 'block';document.getElementById('customerSection').style.display = 'block';document.getElementById('customerChevron').classList.add('open');} else if (p.status === 'negative') {document.getElementById('negativeSectionWrap').style.display = 'block';}14 unmodified linesp.status = s;const card = document.getElementById(`pcard-${i}`);if (card) {card.classList.remove('st-negative','st-pending','st-customer');card.classList.add('st-' + s);card.querySelectorAll('.stt-btn').forEach(b => b.classList.remove('active'));const btnMap = {negative:'stt-neg', pending:'stt-pnd', customer:'stt-cust'};card.querySelector('.' + btnMap[s])?.classList.add('active');}moveCardToSection(i, p);40 unmodified lines<div class="card-footer">${p.has_website? `<a href="${escHtml(p.website)}" target="_blank" class="btn-generate" style="text-decoration:none;text-align:center">Visit site ↗</a>`: `<button class="btn-generate" onclick="openInForm(${i})">Generate Site →</button>`}${(!p.phone || !p.website || !p.email) ? `<button class="btn-autofill" id="fill-${i}" onclick="autoFill(${i})" title="Auto-fill missing contact info">🔍 Auto-fill</button>` : ''}<button class="btn-pin" onclick="pinOnMap(${i})" title="Show on map">📍</button></div><div class="status-row"><span class="status-lbl">Outreach:</span><button class="stt-btn stt-neg${p.status==='negative'?' active':''}" onclick="setStatus(${i},'negative')" title="Not interested">✕</button><button class="stt-btn stt-pnd${p.status==='pending'?' active':''}" onclick="setStatus(${i},'pending')" title="Pending outreach">●</button><button class="stt-btn stt-cust${p.status==='customer'?' active':''}" onclick="setStatus(${i},'customer')" title="Customer">✓</button>${p.status ? `<span class="status-hint">${statusLabel(p.status)}</span>` : ''}</div></div>`;}</script></body>30 unmodified lines3132333435363738394099 unmodified lines14014114214314414514644 unmodified lines19119219319419519619719819920020120220320420520620720820921021121221321421510 unmodified lines2262272282292302312323 unmodified lines23623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227323 unmodified lines29729829930030130230348 unmodified lines35235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241365 unmodified lines479480481482483484485486487488489490491492493494495496206 unmodified lines7037047057067077087097107117127137147157167177187197205 unmodified lines726727728729730731732733734735120 unmodified lines8568578588598608618628638648658668678688698707 unmodified lines87887988088188288388488588688788888989089189213 unmodified lines9069079089099109119129139149159169179189199209219229239249259269279289299309311 unmodified line93393493593693793893994014 unmodified lines95595695795895996096196296396440 unmodified lines10051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110930 unmodified lines.user-name { font-size:.82rem; font-weight:500; }.user-logout { font-size:.78rem; color:var(--muted); text-decoration:none; padding:4px 10px; border-radius:6px; border:1px solid var(--border); transition:color .12s,border-color .12s; white-space:nowrap; }.user-logout:hover { color:var(--red); border-color:var(--red); }.btn-restart { background:var(--surface2); border:1px solid var(--border); color:var(--muted); border-radius:8px; padding:6px 10px; font-size:1rem; cursor:pointer; transition:color .15s,background .15s; }.btn-restart:hover { color:var(--text); background:var(--surface3,#2a2a3a); }.btn-restart.spinning { animation:spin .7s linear infinite; color:var(--accent); }@keyframes spin { to { transform:rotate(360deg); } }/* page */.page { max-width:1280px; margin:0 auto; padding:32px 32px 64px; }99 unmodified lines}.section-count.red { background:rgba(248,113,113,.15); color:var(--red); border:1px solid rgba(248,113,113,.3); }.section-count.green { background:rgba(74,222,128,.15); color:var(--green); border:1px solid rgba(74,222,128,.3); }.section-count.orange { background:rgba(251,146,60,.15); color:#fb923c; border:1px solid rgba(251,146,60,.3); }.section-chevron { margin-left:auto; color:var(--muted); font-size:.75rem; transition:transform .2s; }.section-chevron.open { transform:rotate(180deg); }44 unmodified lines}.btn-autofill:hover { color:var(--yellow); border-color:var(--yellow); }.btn-autofill:disabled { opacity:.4; cursor:not-allowed; }.btn-demo {flex:1; padding:8px 0; background:var(--surface2); border:1px solid #fb923c;border-radius:8px; color:#fb923c; font-size:.82rem; font-weight:600; cursor:pointer;transition:opacity .15s,background .15s;}.btn-demo:hover { background:rgba(251,146,60,.12); }.btn-demo:disabled { opacity:.4; cursor:not-allowed; }.demo-status {font-size:.78rem; color:var(--muted); padding:6px 0 2px;display:flex; align-items:center; gap:8px; flex-wrap:wrap;}.demo-status a { color:var(--accent); text-decoration:none; font-weight:600; }.demo-status a:hover { text-decoration:underline; }.demo-copy {padding:4px 10px; background:var(--surface2); border:1px solid var(--border);border-radius:6px; color:var(--muted); font-size:.75rem; cursor:pointer;transition:color .15s,border-color .15s;}.demo-copy:hover { color:var(--accent); border-color:var(--accent); }/* status buttons */.status-row {10 unmodified lines.stt-btn.stt-neg:hover, .stt-btn.stt-neg.active { background:rgba(248,113,113,.18); border-color:var(--red); color:var(--red); }.stt-btn.stt-pnd:hover, .stt-btn.stt-pnd.active { background:rgba(251,191,36,.18); border-color:var(--yellow); color:var(--yellow); }.stt-btn.stt-cust:hover, .stt-btn.stt-cust.active { background:rgba(74,222,128,.18); border-color:var(--green); color:var(--green); }.stt-btn.stt-star:hover, .stt-btn.stt-star.active { background:rgba(251,146,60,.18); border-color:#fb923c; color:#fb923c; }.status-hint { font-size:.7rem; color:var(--muted); margin-left:4px; }/* card border per status */3 unmodified lines.prospect-card.st-pending:hover { border-color:var(--yellow); }.prospect-card.st-customer { border-color:rgba(74,222,128,.55); }.prospect-card.st-customer:hover { border-color:var(--green); }.prospect-card.st-interesting { border-color:rgba(251,146,60,.55); }.prospect-card.st-interesting:hover { border-color:#fb923c; }/* tips panel */.tips-toggle {display:inline-flex; align-items:center; gap:5px; margin-top:10px;font-size:.78rem; color:var(--muted); cursor:pointer; user-select:none;background:none; border:none; padding:0; transition:color .15s;}.tips-toggle:hover { color:var(--text); }.tips-toggle .chev { display:inline-block; transition:transform .2s; font-size:.65rem; }.tips-toggle .chev.open { transform:rotate(180deg); }.tips-panel {display:none; margin-top:14px; padding:16px 18px;background:rgba(108,99,255,.07); border:1px solid rgba(108,99,255,.2);border-radius:10px; font-size:.82rem; line-height:1.65;}.tips-panel.show { display:block; }.tips-grid { display:grid; grid-template-columns:1fr 1fr; gap:16px; }.tip-section h4 { font-size:.78rem; font-weight:700; color:var(--accent); margin-bottom:8px; letter-spacing:.04em; text-transform:uppercase; }.tip-row { display:flex; gap:8px; margin-bottom:6px; align-items:flex-start; }.tip-row .tag {font-size:.68rem; font-weight:700; padding:2px 7px; border-radius:99px;white-space:nowrap; flex-shrink:0; margin-top:2px;}.tag-green { background:rgba(74,222,128,.15); color:var(--green); border:1px solid rgba(74,222,128,.25); }.tag-yellow { background:rgba(251,191,36,.15); color:var(--yellow); border:1px solid rgba(251,191,36,.25); }.tag-muted { background:var(--surface2); color:var(--muted); border:1px solid var(--border); }.tip-row p { color:var(--muted); font-size:.79rem; margin:0; }.tip-row strong { color:var(--text); font-weight:600; }.tips-divider { width:1px; background:var(--border); }@media(max-width:640px) { .tips-grid { grid-template-columns:1fr; } .tips-divider { display:none; } }/* no-results */.empty-state {23 unmodified lines<a href="/businesses" class="nav-link accent">📋 Businesses</a></nav><div class="topbar-sep"></div><button class="btn-restart" onclick="restartApp(this)" title="Restart server">↺</button><div class="user-pill"><div class="user-avatar">{{ username[0] }}</div><span class="user-name">{{ username }}</span>48 unmodified lines</button></div><!-- Tips --><button class="tips-toggle" onclick="toggleTips(this)">💡 Tips for best results <span class="chev" id="tipsChev">▼</span></button><div class="tips-panel" id="tipsPanel"><div class="tips-grid"><div class="tip-section"><h4>📍 Where to search</h4><div class="tip-row"><span class="tag tag-green">Best</span><p><strong>Towns 20k–150k population</strong> — low agency competition, owners decide fast, many businesses with no site.</p></div><div class="tip-row"><span class="tag tag-yellow">OK</span><p><strong>Outer districts of capitals</strong> — search suburbs, not city centre. Centre is saturated.</p></div><div class="tip-row"><span class="tag tag-muted">Avoid</span><p><strong>City centres & villages under 5k</strong> — either already covered or no budget.</p></div><div class="tip-row" style="margin-top:10px"><span class="tag tag-muted">HU</span><p>Try: Győr, Pécs, Debrecen, Miskolc, Eger, Székesfehérvár</p></div><div class="tip-row"><span class="tag tag-muted">FI</span><p>Try: Tampere, Oulu, Jyväskylä, Lahti, Kuopio</p></div></div><div class="tips-divider"></div><div class="tip-section"><h4>🏢 Best business types</h4><div class="tip-row"><span class="tag tag-green">🔧 Trades</span><p><strong>Plumber & Electrician first.</strong> One job from Google pays site 10×. They know it. Owner decides on the spot.</p></div><div class="tip-row"><span class="tag tag-green">🦷 Healthcare</span><p><strong>Dentist, Physiotherapist</strong> — need credibility + bookings. Higher budget, easier yes.</p></div><div class="tip-row"><span class="tag tag-yellow">💇 Beauty</span><p>Hair & nail salons want online booking. Owner-run = fast decision, but tighter budget.</p></div><div class="tip-row"><span class="tag tag-yellow">🥐 Food</span><p>Bakeries & cafes — high visual impact. Restaurants are harder (thin margins, Wolt/Tripadvisor already covers them).</p></div><div class="tip-row"><span class="tag tag-muted">Radius</span><p>Use <strong>1–3 km</strong> in towns, <strong>5–10 km</strong> in rural areas. Too wide = noise.</p></div></div></div></div><!-- Search + enrich progress --><div class="search-progress" id="searchProgress"><div class="progress-track">65 unmodified lines</div></div><!-- Interesting group --><div id="interestingSectionWrap" style="display:none"><div class="section-head" onclick="toggleSection('interestingSection', this)" style="margin-top:28px"><span class="section-label">⭐ Interesting</span><span class="section-count orange" id="interestingCount">0</span><span class="section-chevron open" id="interestingChevron">▼</span></div><div id="interestingSection"><div class="prospects-grid" id="interestingGrid"></div></div></div><!-- Not interested group (shown when first negative set) --><div id="negativeSectionWrap" style="display:none"><div class="section-head" onclick="toggleSection('negativeSection', this)" style="margin-top:28px">206 unmodified linesdocument.getElementById('statNoSite').textContent = noSite;document.getElementById('statHasSite').textContent = hasSite;// section counts (exclude bucketed statuses from main sections)const _bucketed = s => s === 'customer' || s === 'interesting' || s === 'negative';const inNoSite = ps.filter(p => !p.has_website && !_bucketed(p.status)).length;const inHasSite = ps.filter(p => p.has_website && !_bucketed(p.status)).length;const inCustomer = ps.filter(p => p.status === 'customer').length;const inInteresting = ps.filter(p => p.status === 'interesting').length;const inNegative = ps.filter(p => p.status === 'negative').length;document.getElementById('noSiteCount').textContent = inNoSite;document.getElementById('hasSiteCount').textContent = inHasSite;document.getElementById('customerCount').textContent = inCustomer;document.getElementById('interestingCount').textContent = inInteresting;document.getElementById('negativeCount').textContent = inNegative;}function renderResults(data) {5 unmodified linesdocument.getElementById('noSiteGrid').innerHTML = noSite.map(p => renderCard(p, window._prospects.indexOf(p))).join('');document.getElementById('hasSiteGrid').innerHTML = hasSite.map(p => renderCard(p, window._prospects.indexOf(p))).join('');document.getElementById('customerGrid').innerHTML = '';document.getElementById('interestingGrid').innerHTML = '';document.getElementById('negativeGrid').innerHTML = '';document.getElementById('customerSectionWrap').style.display = 'none';document.getElementById('interestingSectionWrap').style.display = 'none';document.getElementById('negativeSectionWrap').style.display = 'none';updateSummaryBar();120 unmodified lines}}function toggleTips(btn) {const panel = document.getElementById('tipsPanel');const chev = document.getElementById('tipsChev');const open = panel.classList.toggle('show');chev.classList.toggle('open', open);}function statusLabel(s) {return {negative:'Not interested', pending:'Pending', interesting:'Interesting', customer:'Customer'}[s] || '';}// ── CRM status ─────────────────────────────────────────────────────────────7 unmodified linesif (!card) return;// update border classcard.classList.remove('st-negative','st-pending','st-interesting','st-customer');if (newStatus) card.classList.add('st-' + newStatus);// update button active state + hint textcard.querySelectorAll('.stt-btn').forEach(b => b.classList.remove('active'));const btnMap = {negative:'stt-neg', pending:'stt-pnd', interesting:'stt-star', customer:'stt-cust'};if (newStatus) card.querySelector('.' + btnMap[newStatus])?.classList.add('active');const hint = card.querySelector('.status-hint');const labels = {negative:'Not interested', pending:'Pending', interesting:'Interesting', customer:'Customer'};if (hint) { hint.textContent = labels[newStatus] || ''; }else if (newStatus) {const h = document.createElement('span');13 unmodified lineslat: p.lat, lng: p.lng, country: p.country_code,website: p.website || '', phone: p.phone || '', email: p.email || '',}),}).then(r => {if (!r.ok) {// revert UI on failurep.status = p.status === newStatus ? '' : p.status;card.classList.remove('st-' + newStatus);card.querySelector('.' + (btnMap[newStatus]||''))?.classList.remove('active');alert('Failed to save status — please reload and try again.');}}).catch(() => alert('Network error saving status.'));}function moveCardToSection(idx, p) {const card = document.getElementById(`pcard-${idx}`);if (!card) return;const targetId = p.status === 'customer' ? 'customerGrid': p.status === 'interesting' ? 'interestingGrid': p.status === 'negative' ? 'negativeGrid': p.has_website ? 'hasSiteGrid': 'noSiteGrid';document.getElementById(targetId).prepend(card);if (p.status === 'customer') {1 unmodified linewrap.style.display = 'block';document.getElementById('customerSection').style.display = 'block';document.getElementById('customerChevron').classList.add('open');} else if (p.status === 'interesting') {document.getElementById('interestingSectionWrap').style.display = 'block';} else if (p.status === 'negative') {document.getElementById('negativeSectionWrap').style.display = 'block';}14 unmodified linesp.status = s;const card = document.getElementById(`pcard-${i}`);if (card) {card.classList.remove('st-negative','st-pending','st-interesting','st-customer');card.classList.add('st-' + s);card.querySelectorAll('.stt-btn').forEach(b => b.classList.remove('active'));const btnMap = {negative:'stt-neg', pending:'stt-pnd', interesting:'stt-star', customer:'stt-cust'};card.querySelector('.' + btnMap[s])?.classList.add('active');}moveCardToSection(i, p);40 unmodified lines<div class="card-footer">${p.has_website? `<a href="${escHtml(p.website)}" target="_blank" class="btn-generate" style="text-decoration:none;text-align:center">Visit site ↗</a>`: `<button class="btn-generate" onclick="openInForm(${i})">Customize →</button><button class="btn-demo" id="demo-btn-${i}" onclick="quickDemo(${i})">⚡ Quick Demo</button>`}<div class="demo-status" id="demo-status-${i}" style="display:none"></div>${(!p.phone || !p.website || !p.email) ? `<button class="btn-autofill" id="fill-${i}" onclick="autoFill(${i})" title="Auto-fill missing contact info">🔍 Auto-fill</button>` : ''}<button class="btn-pin" onclick="pinOnMap(${i})" title="Show on map">📍</button></div><div class="status-row"><span class="status-lbl">Outreach:</span><button class="stt-btn stt-neg${p.status==='negative'?' active':''}" onclick="setStatus(${i},'negative')" title="Not interested">✕</button><button class="stt-btn stt-pnd${p.status==='pending'?' active':''}" onclick="setStatus(${i},'pending')" title="Pending outreach">●</button><button class="stt-btn stt-star${p.status==='interesting'?' active':''}" onclick="setStatus(${i},'interesting')" title="Interesting">★</button><button class="stt-btn stt-cust${p.status==='customer'?' active':''}" onclick="setStatus(${i},'customer')" title="Customer">✓</button>${p.status ? `<span class="status-hint">${statusLabel(p.status)}</span>` : ''}</div></div>`;}async function quickDemo(idx) {const p = window._prospects[idx];if (!p) return;const btn = document.getElementById(`demo-btn-${idx}`);const statusEl = document.getElementById(`demo-status-${idx}`);btn.disabled = true;btn.textContent = '⏳ Generating…';statusEl.style.display = 'flex';statusEl.textContent = 'Building demo site…';const city = (p.address || '').split(',').slice(-2).join(',').trim();const form = {name: p.name,type: p.type || 'restaurant',address: p.address || '',phone: p.phone || '',email: p.email || '',city,site_language: 'fi',deploy_github: false,deploy_cloudflare: false,};let job_id;try {const r = await fetch('/generate', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify(form) });const data = await r.json();if (!r.ok) throw new Error(data.error || 'Generate failed');job_id = data.job_id;} catch(e) {statusEl.textContent = '❌ ' + e.message;btn.disabled = false;btn.textContent = '⚡ Quick Demo';return;}// Poll until doneconst poll = async () => {try {const r = await fetch(`/status/${job_id}`);const job = await r.json();if (job.status === 'done' && job.result?.slug) {const slug = job.result.slug;const previewUrl = `${location.origin}/preview/${slug}/index.html`;const sms = `Hei! Huomasin, että ${p.name}:lla ei ole verkkosivustoa. Tein teille ilmaisen demoversion: ${previewUrl} — Kiinnostaisiko ammattimainen sivusto? Minut tavoittaa täältä.`;btn.textContent = '✓ Done';statusEl.innerHTML = `<a href="${previewUrl}" target="_blank">View demo ↗</a><button class="demo-copy" onclick="navigator.clipboard.writeText(${JSON.stringify(previewUrl)}).then(()=>{this.textContent='Copied!';setTimeout(()=>this.textContent='Copy link',1500)})">Copy link</button><button class="demo-copy" onclick="navigator.clipboard.writeText(${JSON.stringify(sms)}).then(()=>{this.textContent='Copied!';setTimeout(()=>this.textContent='Copy SMS',1500)})">Copy SMS</button>`;} else if (job.status === 'error') {statusEl.textContent = '❌ ' + (job.error || 'Generation failed');btn.disabled = false;btn.textContent = '⚡ Quick Demo';} else {const lastLog = (job.log || []).slice(-1)[0]?.msg || 'Working…';statusEl.textContent = lastLog;setTimeout(poll, 1500);}} catch { setTimeout(poll, 2000); }};setTimeout(poll, 2000);}async function restartApp(btn) {btn.classList.add('spinning');btn.disabled = true;await fetch('/api/restart', { method: 'POST' }).catch(() => {});const deadline = Date.now() + 30000;const ping = () => {if (Date.now() > deadline) {btn.classList.remove('spinning');btn.disabled = false;btn.title = 'Restart failed — check server logs';return;}fetch('/').then(() => location.reload()).catch(() => setTimeout(ping, 700));};setTimeout(ping, 1500);}</script></body>
app.py+139-24
db.py+8-4
generator.py+4-2
templates/businesses.html+580-24
templates/dashboard.html+22
templates/prospects.html+258-24