feat: initialize market app with browsing, product, and scraping code
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
Split from coop monolith. Includes: - Market/browse/product blueprints - Product sync API - Suma scraping pipeline - Templates for market, browse, and product views - Dockerfile and CI workflow for independent deployment
This commit is contained in:
12
bp/browse/services/blacklist/category.py
Normal file
12
bp/browse/services/blacklist/category.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# suma_browser/category_blacklist.py
|
||||
from __future__ import annotations
|
||||
from typing import Optional
|
||||
from config import config
|
||||
|
||||
def _norm(s: str) -> str:
|
||||
return (s or "").strip().lower().strip("/")
|
||||
|
||||
def is_category_blocked(top_slug: str, sub_slug: Optional[str] = None) -> bool:
|
||||
if sub_slug:
|
||||
return is_category_blocked(top_slug) or _norm(f"{top_slug}/{sub_slug}") in config()["blacklist"]["category"]
|
||||
return _norm(top_slug) in config()["blacklist"]["category"]
|
||||
15
bp/browse/services/blacklist/product.py
Normal file
15
bp/browse/services/blacklist/product.py
Normal file
@@ -0,0 +1,15 @@
|
||||
from typing import Set, Optional
|
||||
from ..slugs import canonical_html_slug
|
||||
from config import config
|
||||
|
||||
_blocked: Set[str] = set()
|
||||
_mtime: Optional[float] = None
|
||||
|
||||
def _norm(slug: str) -> str:
|
||||
slug = (slug or "").strip().strip("/").lower()
|
||||
if slug.startswith("product/"):
|
||||
slug = slug.split("/", 1)[1]
|
||||
return canonical_html_slug(slug)
|
||||
|
||||
def is_product_blocked(slug: str) -> bool:
|
||||
return _norm(slug) in config()["blacklist"]["product"]
|
||||
11
bp/browse/services/blacklist/product_details.py
Normal file
11
bp/browse/services/blacklist/product_details.py
Normal file
@@ -0,0 +1,11 @@
|
||||
import re
|
||||
from config import config
|
||||
|
||||
def _norm_title_key(t: str) -> str:
|
||||
t = (t or "").strip().lower()
|
||||
t = re.sub(r":\s*$", "", t)
|
||||
t = re.sub(r"\s+", " ", t)
|
||||
return t
|
||||
|
||||
def is_blacklisted_heading(title: str) -> bool:
|
||||
return _norm_title_key(title) in [s.lower() for s in config()["blacklist"]["product-details"]]
|
||||
Reference in New Issue
Block a user