Spaces:
Running
Running
Server: đăng ký Imudex + merge H2 pages (catpage/catpdf/deeplink)
Browse files
index.ts
CHANGED
|
@@ -1013,7 +1013,8 @@ const server = Bun.serve({
|
|
| 1013 |
const pageNum = Math.max(1, parseInt(String((req.params as any)?.page || "1"), 10) || 1);
|
| 1014 |
const TITLES: Record<string, string> = {
|
| 1015 |
"catalogue-malloca-2026": "Catalogue Malloca 2026",
|
| 1016 |
-
"new-products-h2-2026": "Sản phẩm mới H2 2026"
|
|
|
|
| 1017 |
};
|
| 1018 |
const catName = TITLES[rawCat] || rawCat;
|
| 1019 |
const pageImg = escURL("https://" + url.host + "/api/catpage?cat=" + encodeURIComponent(rawCat) + "&page=" + pageNum);
|
|
@@ -1234,6 +1235,7 @@ const server = Bun.serve({
|
|
| 1234 |
const PDFS: Record<string, string> = {
|
| 1235 |
"catalogue-malloca-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/pdfs/catalogue_malloca_2026_newest.pdf",
|
| 1236 |
"new-products-h2-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/pdfs/catalogue_new_products_h2_2026.pdf",
|
|
|
|
| 1237 |
};
|
| 1238 |
try {
|
| 1239 |
const name = new URL(req.url).searchParams.get("name") || "catalogue-malloca-2026";
|
|
@@ -1277,13 +1279,18 @@ const server = Bun.serve({
|
|
| 1277 |
// embedded WebViews (e.g. Zalo in-app) that lack a built-in PDF viewer.
|
| 1278 |
const MAP: Record<string,string> = {
|
| 1279 |
"catalogue-malloca-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/catpages/catalogue-malloca-2026/",
|
| 1280 |
-
"new-products-h2-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/catpages/new-products-h2-2026/"
|
|
|
|
| 1281 |
};
|
| 1282 |
try {
|
| 1283 |
const sp=new URL(req.url).searchParams;
|
| 1284 |
const cat=sp.get("cat")||"catalogue-malloca-2026";
|
| 1285 |
-
|
| 1286 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1287 |
const upstream=base+"page_"+String(page).padStart(4,"0")+".jpg";
|
| 1288 |
const resp=await fetch(upstream,{headers:{"User-Agent":"Mozilla/5.0 (compatible; VAI-Avatar2/1.0)"},signal:AbortSignal.timeout(30000)});
|
| 1289 |
if(!resp.ok) return new Response("upstream "+resp.status,{status:502});
|
|
|
|
| 1013 |
const pageNum = Math.max(1, parseInt(String((req.params as any)?.page || "1"), 10) || 1);
|
| 1014 |
const TITLES: Record<string, string> = {
|
| 1015 |
"catalogue-malloca-2026": "Catalogue Malloca 2026",
|
| 1016 |
+
"new-products-h2-2026": "Sản phẩm mới H2 2026",
|
| 1017 |
+
"imudex-2026": "Catalogue Imudex 2026"
|
| 1018 |
};
|
| 1019 |
const catName = TITLES[rawCat] || rawCat;
|
| 1020 |
const pageImg = escURL("https://" + url.host + "/api/catpage?cat=" + encodeURIComponent(rawCat) + "&page=" + pageNum);
|
|
|
|
| 1235 |
const PDFS: Record<string, string> = {
|
| 1236 |
"catalogue-malloca-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/pdfs/catalogue_malloca_2026_newest.pdf",
|
| 1237 |
"new-products-h2-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/pdfs/catalogue_new_products_h2_2026.pdf",
|
| 1238 |
+
"imudex-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/pdfs/imudex_2026.pdf",
|
| 1239 |
};
|
| 1240 |
try {
|
| 1241 |
const name = new URL(req.url).searchParams.get("name") || "catalogue-malloca-2026";
|
|
|
|
| 1279 |
// embedded WebViews (e.g. Zalo in-app) that lack a built-in PDF viewer.
|
| 1280 |
const MAP: Record<string,string> = {
|
| 1281 |
"catalogue-malloca-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/catpages/catalogue-malloca-2026/",
|
| 1282 |
+
"new-products-h2-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/catpages/new-products-h2-2026/",
|
| 1283 |
+
"imudex-2026": "https://huggingface.co/datasets/bep40/grob-products-updated/resolve/main/catpages/imudex-2026/"
|
| 1284 |
};
|
| 1285 |
try {
|
| 1286 |
const sp=new URL(req.url).searchParams;
|
| 1287 |
const cat=sp.get("cat")||"catalogue-malloca-2026";
|
| 1288 |
+
var page=sp.get("page")||"0001";
|
| 1289 |
+
let base=MAP[cat]||MAP["catalogue-malloca-2026"];
|
| 1290 |
+
// Ghép H2 (3 trang) vào Malloca 2026: trang 36-38 = catpages/new-products-h2-2026 (1-3).
|
| 1291 |
+
if(cat==="catalogue-malloca-2026" && parseInt(page,10)>=36){
|
| 1292 |
+
base=MAP["new-products-h2-2026"]||base; page=String(parseInt(page,10)-35);
|
| 1293 |
+
}
|
| 1294 |
const upstream=base+"page_"+String(page).padStart(4,"0")+".jpg";
|
| 1295 |
const resp=await fetch(upstream,{headers:{"User-Agent":"Mozilla/5.0 (compatible; VAI-Avatar2/1.0)"},signal:AbortSignal.timeout(30000)});
|
| 1296 |
if(!resp.ok) return new Response("upstream "+resp.status,{status:502});
|