diff --git a/blueprints/admin/routes_portal_seo.py b/blueprints/admin/routes_portal_seo.py index 90cfd54..d33879e 100644 --- a/blueprints/admin/routes_portal_seo.py +++ b/blueprints/admin/routes_portal_seo.py @@ -74,30 +74,42 @@ def admin_portal_seo_run(): tech = result.get('technical', {}) on_page = result.get('on_page', {}) + sec = result.get('security_headers', {}) + audit = PortalSEOAudit( audited_at=datetime.now(), url=PORTAL_URL, + # PageSpeed scores pagespeed_performance=ps_scores.get('performance'), pagespeed_seo=ps_scores.get('seo'), pagespeed_accessibility=ps_scores.get('accessibility'), pagespeed_best_practices=ps_scores.get('best_practices'), - overall_score=result.get('overall_score'), - on_page_score=on_page.get('score'), - technical_score=tech.get('score'), - local_seo_score=result.get('local_seo', {}).get('score'), + # Core Web Vitals lcp_ms=cwv.get('lcp_ms'), fcp_ms=cwv.get('fcp_ms'), cls=cwv.get('cls'), tbt_ms=cwv.get('tbt_ms'), + speed_index_ms=cwv.get('speed_index_ms'), + # On-page checks + has_meta_title=bool(on_page.get('meta_title')), + has_meta_description=bool(on_page.get('meta_description')), + has_canonical=tech.get('has_canonical'), has_robots_txt=tech.get('has_robots_txt'), has_sitemap=tech.get('has_sitemap'), - has_canonical=tech.get('has_canonical'), has_structured_data=on_page.get('has_structured_data'), has_og_tags=on_page.get('has_og_tags'), has_ssl=tech.get('has_ssl'), is_mobile_friendly=tech.get('is_mobile_friendly'), - has_hsts=result.get('security_headers', {}).get('has_hsts'), - has_csp=result.get('security_headers', {}).get('has_csp'), + # Security headers + has_hsts=sec.get('has_hsts'), + has_csp=sec.get('has_csp'), + has_x_frame=sec.get('has_x_frame_options'), + has_x_content_type=sec.get('has_x_content_type'), + # Content metrics + page_size_bytes=on_page.get('page_size_bytes'), + image_count=on_page.get('total_images'), + images_without_alt=on_page.get('images_without_alt'), + # Full data full_results=result, notes=request.form.get('notes', ''), created_by=current_user.email @@ -106,7 +118,7 @@ def admin_portal_seo_run(): db.add(audit) db.commit() - flash(f'Audyt SEO portalu zakończony. Wynik ogólny: {audit.overall_score or "N/A"}', 'success') + flash(f'Audyt SEO portalu zakończony. Performance: {audit.pagespeed_performance or "N/A"}', 'success') return redirect(url_for('admin.admin_portal_seo')) except Exception as e: diff --git a/database.py b/database.py index 603360a..007b4ab 100644 --- a/database.py +++ b/database.py @@ -5519,22 +5519,19 @@ class PortalSEOAudit(Base): pagespeed_accessibility = Column(Integer) pagespeed_best_practices = Column(Integer) - # Overall scores from SEOAuditor - overall_score = Column(Integer) - on_page_score = Column(Integer) - technical_score = Column(Integer) - local_seo_score = Column(Integer) - # Core Web Vitals lcp_ms = Column(Numeric(10, 2)) fcp_ms = Column(Numeric(10, 2)) cls = Column(Numeric(6, 4)) tbt_ms = Column(Numeric(10, 2)) + speed_index_ms = Column(Numeric(10, 2)) - # Key checks + # On-page SEO checks + has_meta_title = Column(Boolean) + has_meta_description = Column(Boolean) + has_canonical = Column(Boolean) has_robots_txt = Column(Boolean) has_sitemap = Column(Boolean) - has_canonical = Column(Boolean) has_structured_data = Column(Boolean) has_og_tags = Column(Boolean) has_ssl = Column(Boolean) @@ -5543,6 +5540,13 @@ class PortalSEOAudit(Base): # Security headers has_hsts = Column(Boolean) has_csp = Column(Boolean) + has_x_frame = Column(Boolean) + has_x_content_type = Column(Boolean) + + # Content metrics + page_size_bytes = Column(Integer) + image_count = Column(Integer) + images_without_alt = Column(Integer) # Full audit results from SEOAuditor full_results = Column(JSONB) diff --git a/templates/admin/portal_seo.html b/templates/admin/portal_seo.html index b976eec..228a074 100644 --- a/templates/admin/portal_seo.html +++ b/templates/admin/portal_seo.html @@ -158,8 +158,6 @@ {{ score_card('SEO', latest.pagespeed_seo, prev.pagespeed_seo if prev else None) }} {{ score_card('Accessibility', latest.pagespeed_accessibility, prev.pagespeed_accessibility if prev else None) }} {{ score_card('Best Practices', latest.pagespeed_best_practices, prev.pagespeed_best_practices if prev else None) }} - {{ score_card('On-Page', latest.on_page_score, prev.on_page_score if prev else None) }} - {{ score_card('Technical', latest.technical_score, prev.technical_score if prev else None) }} @@ -178,15 +176,19 @@ {% endmacro %} + {{ check_item('Meta Title', latest.has_meta_title) }} + {{ check_item('Meta Description', latest.has_meta_description) }} + {{ check_item('Canonical URL', latest.has_canonical) }} {{ check_item('robots.txt', latest.has_robots_txt) }} {{ check_item('sitemap.xml', latest.has_sitemap) }} - {{ check_item('Canonical URL', latest.has_canonical) }} {{ check_item('Structured Data', latest.has_structured_data) }} {{ check_item('Open Graph', latest.has_og_tags) }} {{ check_item('SSL', latest.has_ssl) }} {{ check_item('Mobile Friendly', latest.is_mobile_friendly) }} {{ check_item('HSTS', latest.has_hsts) }} {{ check_item('CSP', latest.has_csp) }} + {{ check_item('X-Frame-Options', latest.has_x_frame) }} + {{ check_item('X-Content-Type', latest.has_x_content_type) }} @@ -241,8 +243,6 @@