feat: vendor pages /vendor/<slug> with SEO, sitemap updated, links from main
This commit is contained in:
+12
-1
@@ -296,7 +296,8 @@
|
|||||||
? `<img src="/static/${v.logo}" alt="${v.name}" onerror="this.parentElement.innerHTML='<span class=vib-logo-text>${v.name.slice(0,2).toUpperCase()}</span>'">`
|
? `<img src="/static/${v.logo}" alt="${v.name}" onerror="this.parentElement.innerHTML='<span class=vib-logo-text>${v.name.slice(0,2).toUpperCase()}</span>'">`
|
||||||
: `<span class="vib-logo-text">${v.name.slice(0,2).toUpperCase()}</span>`;
|
: `<span class="vib-logo-text">${v.name.slice(0,2).toUpperCase()}</span>`;
|
||||||
let linksHtml = '';
|
let linksHtml = '';
|
||||||
if (v.mont_page) linksHtml += `<a class="vib-link mont" href="${v.mont_page}" target="_blank" rel="noopener">MONT ↗</a>`;
|
if (v.slug) linksHtml += `<a class="vib-link mont" href="/vendor/${v.slug}">Подробнее →</a>`;
|
||||||
|
if (v.mont_page) linksHtml += `<a class="vib-link site" href="${v.mont_page}" target="_blank" rel="noopener">MONT ↗</a>`;
|
||||||
if (v.website) linksHtml += `<a class="vib-link site" href="${v.website}" target="_blank" rel="noopener">Сайт ↗</a>`;
|
if (v.website) linksHtml += `<a class="vib-link site" href="${v.website}" target="_blank" rel="noopener">Сайт ↗</a>`;
|
||||||
bar.innerHTML = `
|
bar.innerHTML = `
|
||||||
<div class="vib-logo">${logoInner}</div>
|
<div class="vib-logo">${logoInner}</div>
|
||||||
@@ -313,7 +314,17 @@
|
|||||||
const card = document.createElement("article");
|
const card = document.createElement("article");
|
||||||
card.className = "row-card";
|
card.className = "row-card";
|
||||||
const title = document.createElement("strong");
|
const title = document.createElement("strong");
|
||||||
|
if (row.vendor.slug) {
|
||||||
|
const a = document.createElement("a");
|
||||||
|
a.href = `/vendor/${row.vendor.slug}`;
|
||||||
|
a.textContent = row.vendor.name;
|
||||||
|
a.style.cssText = "color:inherit;text-decoration:none;";
|
||||||
|
a.addEventListener("mouseenter", () => a.style.textDecoration = "underline");
|
||||||
|
a.addEventListener("mouseleave", () => a.style.textDecoration = "none");
|
||||||
|
title.appendChild(a);
|
||||||
|
} else {
|
||||||
title.textContent = row.vendor.name;
|
title.textContent = row.vendor.name;
|
||||||
|
}
|
||||||
card.appendChild(title);
|
card.appendChild(title);
|
||||||
const tags = document.createElement("div");
|
const tags = document.createElement("div");
|
||||||
tags.className = "tags";
|
tags.className = "tags";
|
||||||
|
|||||||
@@ -0,0 +1,194 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="ru">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<title>{{ vendor.name }} — вендор МОНТ | матрица продуктов MONT</title>
|
||||||
|
<meta name="description" content="{{ vendor.description[:160] if vendor.description else 'Вендор ' + vendor.name + ' в корзине продуктов дистрибьютора МОНТ. Продукты, категории, ссылки.' }}" />
|
||||||
|
<meta name="robots" content="index, follow" />
|
||||||
|
<link rel="canonical" href="{{ canonical_url }}" />
|
||||||
|
|
||||||
|
<meta property="og:type" content="website" />
|
||||||
|
<meta property="og:url" content="{{ canonical_url }}" />
|
||||||
|
<meta property="og:title" content="{{ vendor.name }} — вендор МОНТ" />
|
||||||
|
<meta property="og:description" content="{{ vendor.description[:200] if vendor.description else 'Вендор ' + vendor.name + ' в корзине продуктов дистрибьютора МОНТ.' }}" />
|
||||||
|
{% if vendor.logo %}<meta property="og:image" content="{{ base_url }}/static/{{ vendor.logo }}" />{% endif %}
|
||||||
|
|
||||||
|
<script type="application/ld+json">
|
||||||
|
{
|
||||||
|
"@context": "https://schema.org",
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "{{ vendor.name }}",
|
||||||
|
"description": "{{ vendor.description | replace('"', '\\"') if vendor.description else '' }}",
|
||||||
|
{% if vendor.website %}"url": "{{ vendor.website }}",{% endif %}
|
||||||
|
{% if vendor.logo %}"logo": "{{ base_url }}/static/{{ vendor.logo }}",{% endif %}
|
||||||
|
"distributor": {
|
||||||
|
"@type": "Organization",
|
||||||
|
"name": "МОНТ",
|
||||||
|
"url": "{{ base_url }}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<link rel="icon" type="image/png" href="/static/favicon.png" />
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;600;700;800&display=swap" rel="stylesheet">
|
||||||
|
<style>
|
||||||
|
:root { --brand: #1f4ea3; --brand2: #3978e0; --bg: #eef4ff; --radius: 16px; }
|
||||||
|
* { box-sizing: border-box; }
|
||||||
|
body { margin: 0; font-family: Manrope, sans-serif; background: var(--bg); color: #15203b; min-height: 100vh; }
|
||||||
|
.wrap { width: min(960px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 60px; }
|
||||||
|
|
||||||
|
.breadcrumb { font-size: 13px; color: #526079; margin-bottom: 20px; }
|
||||||
|
.breadcrumb a { color: var(--brand); text-decoration: none; font-weight: 600; }
|
||||||
|
.breadcrumb a:hover { text-decoration: underline; }
|
||||||
|
|
||||||
|
.vendor-card {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 20px;
|
||||||
|
border: 1px solid #dae6ff;
|
||||||
|
box-shadow: 0 12px 40px rgba(16,43,95,.1);
|
||||||
|
padding: 32px;
|
||||||
|
display: flex;
|
||||||
|
gap: 28px;
|
||||||
|
align-items: flex-start;
|
||||||
|
margin-bottom: 28px;
|
||||||
|
}
|
||||||
|
.vendor-logo-box {
|
||||||
|
flex-shrink: 0;
|
||||||
|
width: 200px;
|
||||||
|
height: 120px;
|
||||||
|
background: #f5f8ff;
|
||||||
|
border-radius: 14px;
|
||||||
|
border: 1px solid #e0eaff;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 16px;
|
||||||
|
}
|
||||||
|
.vendor-logo-box img { max-width: 100%; max-height: 88px; object-fit: contain; }
|
||||||
|
.vendor-logo-placeholder { font-size: 42px; font-weight: 800; color: var(--brand); }
|
||||||
|
.vendor-info { flex: 1; min-width: 0; }
|
||||||
|
.vendor-name { font-size: 26px; font-weight: 800; color: #1a3e79; margin: 0 0 10px; }
|
||||||
|
.vendor-desc { font-size: 15px; color: #3a4f6e; line-height: 1.65; margin: 0 0 18px; }
|
||||||
|
.vendor-links { display: flex; gap: 10px; flex-wrap: wrap; }
|
||||||
|
.vlink {
|
||||||
|
display: inline-flex; align-items: center; gap: 6px;
|
||||||
|
font-size: 13px; font-weight: 700; padding: 8px 18px;
|
||||||
|
border-radius: 999px; text-decoration: none; transition: .15s ease;
|
||||||
|
}
|
||||||
|
.vlink.mont { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
|
||||||
|
.vlink.site { background: #eef4ff; color: var(--brand); border: 1px solid #c8d8f7; }
|
||||||
|
.vlink:hover { opacity: .85; transform: translateY(-1px); }
|
||||||
|
|
||||||
|
.section-title {
|
||||||
|
font-size: 18px; font-weight: 800; color: #1a3e79;
|
||||||
|
margin: 0 0 14px; padding-bottom: 10px;
|
||||||
|
border-bottom: 2px solid #e8f0ff;
|
||||||
|
}
|
||||||
|
.products-box {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid #dae6ff;
|
||||||
|
padding: 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
.products-grid { display: flex; flex-wrap: wrap; gap: 8px; }
|
||||||
|
.product-tag {
|
||||||
|
font-size: 13px; font-weight: 600;
|
||||||
|
padding: 6px 14px; border-radius: 999px;
|
||||||
|
background: linear-gradient(135deg, #f0f6ff, #e4efff);
|
||||||
|
color: #1e4a8d; border: 1px solid #c8dcff;
|
||||||
|
text-decoration: none; transition: .15s ease;
|
||||||
|
}
|
||||||
|
a.product-tag:hover {
|
||||||
|
background: linear-gradient(135deg, #daeaff, #c8ddff);
|
||||||
|
transform: translateY(-1px);
|
||||||
|
}
|
||||||
|
.cats-box {
|
||||||
|
background: #fff;
|
||||||
|
border-radius: 16px;
|
||||||
|
border: 1px solid #dae6ff;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
.cat-chip {
|
||||||
|
display: inline-block; font-size: 12px; font-weight: 600;
|
||||||
|
padding: 5px 12px; border-radius: 999px; margin: 4px;
|
||||||
|
background: #f7faff; color: #22427a; border: 1px solid #ccdbf7;
|
||||||
|
}
|
||||||
|
.back-btn {
|
||||||
|
display: inline-flex; align-items: center; gap: 6px;
|
||||||
|
font-size: 13px; font-weight: 700; color: var(--brand);
|
||||||
|
text-decoration: none; margin-bottom: 20px;
|
||||||
|
padding: 8px 16px; border-radius: 999px;
|
||||||
|
background: #fff; border: 1px solid #c8d8f7;
|
||||||
|
transition: .15s ease;
|
||||||
|
}
|
||||||
|
.back-btn:hover { background: #eef4ff; transform: translateX(-2px); }
|
||||||
|
|
||||||
|
@media (max-width: 640px) {
|
||||||
|
.vendor-card { flex-direction: column; padding: 20px; }
|
||||||
|
.vendor-logo-box { width: 100%; height: 100px; }
|
||||||
|
.vendor-name { font-size: 20px; }
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="wrap">
|
||||||
|
<a href="/" class="back-btn">← Все вендоры МОНТ</a>
|
||||||
|
|
||||||
|
<nav class="breadcrumb" aria-label="breadcrumb">
|
||||||
|
<a href="/">Корзина МОНТ</a> › {{ vendor.name }}
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<div class="vendor-card">
|
||||||
|
<div class="vendor-logo-box">
|
||||||
|
{% if vendor.logo %}
|
||||||
|
<img src="/static/{{ vendor.logo }}" alt="{{ vendor.name }} логотип" />
|
||||||
|
{% else %}
|
||||||
|
<span class="vendor-logo-placeholder">{{ vendor.name[:2].upper() }}</span>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
<div class="vendor-info">
|
||||||
|
<h1 class="vendor-name">{{ vendor.name }}</h1>
|
||||||
|
{% if vendor.description %}
|
||||||
|
<p class="vendor-desc">{{ vendor.description }}</p>
|
||||||
|
{% endif %}
|
||||||
|
<div class="vendor-links">
|
||||||
|
{% if vendor.mont_page %}
|
||||||
|
<a class="vlink mont" href="{{ vendor.mont_page }}" target="_blank" rel="noopener">Страница на МОНТ ↗</a>
|
||||||
|
{% endif %}
|
||||||
|
{% if vendor.website %}
|
||||||
|
<a class="vlink site" href="{{ vendor.website }}" target="_blank" rel="noopener">Официальный сайт ↗</a>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{% if products %}
|
||||||
|
<div class="products-box">
|
||||||
|
<h2 class="section-title">Продукты {{ vendor.name }} в корзине МОНТ</h2>
|
||||||
|
<div class="products-grid">
|
||||||
|
{% for p in products %}
|
||||||
|
{% if p.url %}
|
||||||
|
<a class="product-tag" href="{{ p.url }}" target="_blank" rel="noopener">{{ p.name }} ↗</a>
|
||||||
|
{% else %}
|
||||||
|
<span class="product-tag">{{ p.name }}</span>
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if categories %}
|
||||||
|
<div class="cats-box">
|
||||||
|
<h2 class="section-title">Категории</h2>
|
||||||
|
{% for c in categories %}
|
||||||
|
<span class="cat-chip">{{ c }}</span>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+1
-1
@@ -411,7 +411,7 @@ def fetch_scope_data(scope: str) -> dict:
|
|||||||
conn = get_db()
|
conn = get_db()
|
||||||
vendors = [dict(r) for r in conn.execute(
|
vendors = [dict(r) for r in conn.execute(
|
||||||
f"SELECT id, name, COALESCE(logo,'') as logo, COALESCE(description,'') as description, "
|
f"SELECT id, name, COALESCE(logo,'') as logo, COALESCE(description,'') as description, "
|
||||||
f"COALESCE(website,'') as website, COALESCE(mont_page,'') as mont_page "
|
f"COALESCE(website,'') as website, COALESCE(mont_page,'') as mont_page, COALESCE(slug,'') as slug "
|
||||||
f"FROM {tables['vendors']} ORDER BY lower(name)"
|
f"FROM {tables['vendors']} ORDER BY lower(name)"
|
||||||
)]
|
)]
|
||||||
categories = [dict(r) for r in conn.execute(f"SELECT id, name FROM {tables['categories']} ORDER BY lower(name)")]
|
categories = [dict(r) for r in conn.execute(f"SELECT id, name FROM {tables['categories']} ORDER BY lower(name)")]
|
||||||
|
|||||||
+56
-2
@@ -582,15 +582,69 @@ def sitemap_xml():
|
|||||||
from flask import Response
|
from flask import Response
|
||||||
proto = request.headers.get("X-Forwarded-Proto", "https")
|
proto = request.headers.get("X-Forwarded-Proto", "https")
|
||||||
base = f"{proto}://{request.host}"
|
base = f"{proto}://{request.host}"
|
||||||
|
conn = get_db()
|
||||||
|
slugs = [r[0] for r in conn.execute(
|
||||||
|
"SELECT slug FROM vendors WHERE slug IS NOT NULL "
|
||||||
|
"UNION SELECT slug FROM ib_vendors WHERE slug IS NOT NULL"
|
||||||
|
)]
|
||||||
|
conn.close()
|
||||||
|
urls = [f' <url><loc>{base}/</loc><changefreq>weekly</changefreq><priority>1.0</priority></url>']
|
||||||
|
for slug in slugs:
|
||||||
|
urls.append(f' <url><loc>{base}/vendor/{slug}</loc><changefreq>monthly</changefreq><priority>0.7</priority></url>')
|
||||||
body = (
|
body = (
|
||||||
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
'<?xml version="1.0" encoding="UTF-8"?>\n'
|
||||||
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
|
'<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n'
|
||||||
f' <url><loc>{base}/</loc><changefreq>weekly</changefreq><priority>1.0</priority></url>\n'
|
+ '\n'.join(urls) + '\n</urlset>'
|
||||||
'</urlset>'
|
|
||||||
)
|
)
|
||||||
return Response(body, mimetype="application/xml")
|
return Response(body, mimetype="application/xml")
|
||||||
|
|
||||||
|
|
||||||
|
@bp.get("/vendor/<slug>")
|
||||||
|
def vendor_page(slug: str):
|
||||||
|
from flask import abort
|
||||||
|
conn = get_db()
|
||||||
|
# Search in both tables, prefer infra
|
||||||
|
vendor = conn.execute(
|
||||||
|
"SELECT id, name, COALESCE(logo,'') as logo, COALESCE(description,'') as description, "
|
||||||
|
"COALESCE(website,'') as website, COALESCE(mont_page,'') as mont_page, 'infra' as scope "
|
||||||
|
"FROM vendors WHERE slug = ?", (slug,)
|
||||||
|
).fetchone()
|
||||||
|
if not vendor:
|
||||||
|
vendor = conn.execute(
|
||||||
|
"SELECT id, name, COALESCE(logo,'') as logo, COALESCE(description,'') as description, "
|
||||||
|
"COALESCE(website,'') as website, COALESCE(mont_page,'') as mont_page, 'ib' as scope "
|
||||||
|
"FROM ib_vendors WHERE slug = ?", (slug,)
|
||||||
|
).fetchone()
|
||||||
|
if not vendor:
|
||||||
|
conn.close()
|
||||||
|
abort(404)
|
||||||
|
|
||||||
|
vendor = dict(vendor)
|
||||||
|
tables = scope_tables(vendor['scope'])
|
||||||
|
|
||||||
|
products = [dict(r) for r in conn.execute(
|
||||||
|
f"SELECT name, COALESCE(url,'') as url FROM {tables['products']} "
|
||||||
|
f"WHERE vendor_id = ? ORDER BY lower(name)", (vendor['id'],)
|
||||||
|
)]
|
||||||
|
categories = [r[0] for r in conn.execute(
|
||||||
|
f"SELECT c.name FROM {tables['categories']} c "
|
||||||
|
f"JOIN {tables['vendor_categories']} vc ON vc.category_id = c.id "
|
||||||
|
f"WHERE vc.vendor_id = ? ORDER BY lower(c.name)", (vendor['id'],)
|
||||||
|
)]
|
||||||
|
conn.close()
|
||||||
|
|
||||||
|
proto = request.headers.get("X-Forwarded-Proto", "https")
|
||||||
|
base_url = f"{proto}://{request.host}"
|
||||||
|
canonical_url = f"{base_url}/vendor/{slug}"
|
||||||
|
return render_template("vendor.html",
|
||||||
|
vendor=vendor,
|
||||||
|
products=products,
|
||||||
|
categories=categories,
|
||||||
|
canonical_url=canonical_url,
|
||||||
|
base_url=base_url,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@bp.get("/api/data")
|
@bp.get("/api/data")
|
||||||
def api_data():
|
def api_data():
|
||||||
scope = (request.args.get("scope") or "infra").strip().lower()
|
scope = (request.args.get("scope") or "infra").strip().lower()
|
||||||
|
|||||||
Reference in New Issue
Block a user