Merge pull request #1454 from pateljannat/issues-93
feat: meta image and keywords from settings
This commit is contained in:
@@ -60,7 +60,10 @@
|
||||
"column_break_uwsp",
|
||||
"payment_reminder_template",
|
||||
"seo_tab",
|
||||
"meta_description"
|
||||
"meta_description",
|
||||
"meta_image",
|
||||
"column_break_xijv",
|
||||
"meta_keywords"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -370,13 +373,29 @@
|
||||
"fieldname": "meta_description",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Meta Description"
|
||||
},
|
||||
{
|
||||
"description": "This image will be shown on lists and pages that don't have an image by default",
|
||||
"fieldname": "meta_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"label": "Meta Image"
|
||||
},
|
||||
{
|
||||
"description": "Common keywords that will be used for all pages",
|
||||
"fieldname": "meta_keywords",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Meta Keywords"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_xijv",
|
||||
"fieldtype": "Column Break"
|
||||
}
|
||||
],
|
||||
"grid_page_length": 50,
|
||||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2025-04-17 21:58:30.365876",
|
||||
"modified": "2025-04-19 12:19:24.037931",
|
||||
"modified_by": "sayali@frappe.io",
|
||||
"module": "LMS",
|
||||
"name": "LMS Settings",
|
||||
|
||||
@@ -14,25 +14,28 @@ def get_context():
|
||||
or "/assets/lms/frontend/favicon.png"
|
||||
)
|
||||
title = frappe.db.get_single_value("Website Settings", "app_name") or "Frappe Learning"
|
||||
description = frappe.db.get_single_value("LMS Settings", "meta_description")
|
||||
|
||||
csrf_token = frappe.sessions.get_csrf_token()
|
||||
frappe.db.commit()
|
||||
|
||||
context = frappe._dict()
|
||||
context.csrf_token = csrf_token
|
||||
context.meta = get_meta(app_path, title, favicon, description)
|
||||
context.meta = get_meta(app_path, title, favicon)
|
||||
capture("active_site", "lms")
|
||||
context.title = title
|
||||
context.favicon = favicon
|
||||
return context
|
||||
|
||||
|
||||
def get_meta(app_path, title, favicon, description):
|
||||
def get_meta(app_path, title, favicon):
|
||||
meta = frappe._dict()
|
||||
if app_path:
|
||||
meta = get_meta_from_document(app_path)
|
||||
|
||||
route_meta = frappe.get_all("Website Meta Tag", {"parent": app_path}, ["key", "value"])
|
||||
description = frappe.db.get_single_value("LMS Settings", "meta_description")
|
||||
image = frappe.db.get_single_value("LMS Settings", "meta_image")
|
||||
keywords = frappe.db.get_single_value("LMS Settings", "meta_keywords")
|
||||
|
||||
if len(route_meta) > 0:
|
||||
for row in route_meta:
|
||||
@@ -54,10 +57,9 @@ def get_meta(app_path, title, favicon, description):
|
||||
meta["description"] = description
|
||||
|
||||
if not meta.get("image"):
|
||||
meta["image"] = favicon
|
||||
meta["image"] = image or favicon
|
||||
|
||||
if not meta.get("keywords"):
|
||||
meta["keywords"] = ""
|
||||
meta["keywords"] = f"{meta.get('keywords')}, {keywords}"
|
||||
|
||||
if not meta:
|
||||
meta = {
|
||||
|
||||
Reference in New Issue
Block a user