Remove WordPress references
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# How Do You Convert – AI Agent SOP
|
||||
|
||||
This repo now ships a **SvelteKit** experience that renders every conversion locally. All calculator logic lives inside `hdyc-svelte`, and the markdown registry plus a generator script drive the data. There are no WordPress posts, Kadence elements, or REST creates involved in the current deployment flow.
|
||||
This repo now ships a **SvelteKit** experience that renders every conversion locally. All calculator logic lives inside `hdyc-svelte`, and the markdown registry plus a generator script drive the data. There are no external CMS posts, Kadence elements, or REST creates involved in the current deployment flow.
|
||||
|
||||
## 1. Architecture overview
|
||||
- `hdyc-svelte` is a SvelteKit + Node app that renders the homepage, category lists, and every `/[slug]` calculator page via server-side rendering.
|
||||
|
||||
56
migrate.py
56
migrate.py
@@ -1,57 +1,11 @@
|
||||
import json
|
||||
import urllib.request
|
||||
import re
|
||||
import math
|
||||
import os
|
||||
|
||||
CALCLIST = '/home/ben/Seafile/Storage/Docs/howdoyouconvert/calculators_list.md'
|
||||
API_URL = 'https://howdoyouconvert.com/wp-json/wp/v2/calculator?per_page=100'
|
||||
|
||||
def fetch_all_wp_calculators():
|
||||
calculators = {}
|
||||
page = 1
|
||||
while True:
|
||||
url = f"{API_URL}&page={page}"
|
||||
print(f"Fetching {url}...")
|
||||
try:
|
||||
req = urllib.request.Request(url, headers={'User-Agent': 'Mozilla/5.0'})
|
||||
with urllib.request.urlopen(req) as response:
|
||||
data = json.loads(response.read().decode())
|
||||
if not data:
|
||||
break
|
||||
for post in data:
|
||||
slug = post['slug']
|
||||
content = post['content']['rendered']
|
||||
|
||||
# Extract SEO paragraphs, ignore the "<!-- more -->" and any scripts
|
||||
# We'll just grab everything inside <p> except ones with strong Kadence layout text if possible
|
||||
# Or simple approach: just grab all text
|
||||
pars = re.findall(r'<p[^>]*>(.*?)</p>', content, re.DOTALL)
|
||||
|
||||
# Clean up paragraphs
|
||||
clean_pars = []
|
||||
for p in pars:
|
||||
p_clean = re.sub(r'<[^>]+>', '', p).replace('\n', ' ').strip()
|
||||
p_clean = re.sub(r'\s+', ' ', p_clean)
|
||||
# Remove first paragraph flavor text boilerplate pattern
|
||||
p_clean = re.sub(r'^.*?: Technical specifications, .*? conversion factors, and historical unit context\.$', '', p_clean)
|
||||
|
||||
if p_clean and "The transformation of this data is governed by universal standard definitions" not in p_clean:
|
||||
pass
|
||||
if p_clean:
|
||||
clean_pars.append(f"<p>{p_clean}</p>")
|
||||
|
||||
calculators[slug] = "\n".join(clean_pars)
|
||||
page += 1
|
||||
except Exception as e:
|
||||
if hasattr(e, 'code') and e.code == 400:
|
||||
# End of pages
|
||||
break
|
||||
print(f"Error fetching page {page}: {e}")
|
||||
break
|
||||
|
||||
# As a fallback if WP API descriptions are purely generic, we just keep what WP generated.
|
||||
return calculators
|
||||
def load_external_descriptions():
|
||||
# Placeholder for future enrichment sources.
|
||||
return {}
|
||||
|
||||
def parse_calculators_list():
|
||||
active_calcs = []
|
||||
@@ -99,7 +53,7 @@ def guess_category(name):
|
||||
return 'other'
|
||||
|
||||
def process():
|
||||
wp_data = fetch_all_wp_calculators()
|
||||
external_descriptions = load_external_descriptions()
|
||||
active_rows = parse_calculators_list()
|
||||
|
||||
calculators_ts_entries = []
|
||||
@@ -115,7 +69,7 @@ def process():
|
||||
in1, in2 = "From", "To"
|
||||
|
||||
category = guess_category(name)
|
||||
desc_html = wp_data.get(slug, "")
|
||||
desc_html = external_descriptions.get(slug, "")
|
||||
|
||||
c_type = 'standard'
|
||||
factor_val = "1"
|
||||
|
||||
Reference in New Issue
Block a user