fix!(portal): remove Homepage

This commit is contained in:
Rushabh Mehta 2024-01-08 15:49:49 +05:30
parent b96c063c93
commit f01f6d50b5
18 changed files with 0 additions and 997 deletions

View File

@ -1,5 +0,0 @@
import frappe
def execute():
frappe.db.set_single_value("Homepage", "hero_section_based_on", "Default")

View File

@ -1,13 +0,0 @@
// Copyright (c) 2016, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Homepage', {
refresh: function(frm) {
frm.add_custom_button(__('Set Meta Tags'), () => {
frappe.utils.set_meta_tag('home');
});
frm.add_custom_button(__('Customize Homepage Sections'), () => {
frappe.set_route('List', 'Homepage Section', 'List');
});
},
});

View File

@ -1,122 +0,0 @@
{
"actions": [],
"beta": 1,
"creation": "2016-04-22 05:27:52.109319",
"doctype": "DocType",
"document_type": "Setup",
"engine": "InnoDB",
"field_order": [
"company",
"hero_section_based_on",
"column_break_2",
"title",
"section_break_4",
"tag_line",
"description",
"hero_image",
"slideshow",
"hero_section"
],
"fields": [
{
"fieldname": "company",
"fieldtype": "Link",
"in_list_view": 1,
"label": "Company",
"options": "Company",
"reqd": 1
},
{
"fieldname": "hero_section_based_on",
"fieldtype": "Select",
"label": "Hero Section Based On",
"options": "Default\nSlideshow\nHomepage Section"
},
{
"fieldname": "column_break_2",
"fieldtype": "Column Break"
},
{
"fieldname": "title",
"fieldtype": "Data",
"label": "Title"
},
{
"fieldname": "section_break_4",
"fieldtype": "Section Break",
"label": "Hero Section"
},
{
"depends_on": "eval:doc.hero_section_based_on === 'Default'",
"description": "Company Tagline for website homepage",
"fieldname": "tag_line",
"fieldtype": "Data",
"in_list_view": 1,
"label": "Tag Line",
"reqd": 1
},
{
"depends_on": "eval:doc.hero_section_based_on === 'Default'",
"description": "Company Description for website homepage",
"fieldname": "description",
"fieldtype": "Text",
"in_list_view": 1,
"label": "Description",
"reqd": 1
},
{
"depends_on": "eval:doc.hero_section_based_on === 'Default'",
"fieldname": "hero_image",
"fieldtype": "Attach Image",
"label": "Hero Image"
},
{
"depends_on": "eval:doc.hero_section_based_on === 'Slideshow'",
"fieldname": "slideshow",
"fieldtype": "Link",
"label": "Homepage Slideshow",
"options": "Website Slideshow"
},
{
"depends_on": "eval:doc.hero_section_based_on === 'Homepage Section'",
"fieldname": "hero_section",
"fieldtype": "Link",
"label": "Homepage Section",
"options": "Homepage Section"
}
],
"issingle": 1,
"links": [],
"modified": "2022-12-19 21:10:29.127277",
"modified_by": "Administrator",
"module": "Portal",
"name": "Homepage",
"owner": "Administrator",
"permissions": [
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "System Manager",
"share": 1,
"write": 1
},
{
"create": 1,
"delete": 1,
"email": 1,
"print": 1,
"read": 1,
"role": "Administrator",
"share": 1,
"write": 1
}
],
"sort_field": "modified",
"sort_order": "DESC",
"states": [],
"title_field": "company",
"track_changes": 1
}

View File

@ -1,32 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
import frappe
from frappe.model.document import Document
from frappe.website.utils import delete_page_cache
class Homepage(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
company: DF.Link
description: DF.Text
hero_image: DF.AttachImage | None
hero_section: DF.Link | None
hero_section_based_on: DF.Literal["Default", "Slideshow", "Homepage Section"]
slideshow: DF.Link | None
tag_line: DF.Data
title: DF.Data | None
# end: auto-generated types
def validate(self):
if not self.description:
self.description = frappe._("This is an example website auto-generated from ERPNext")
delete_page_cache("home")

View File

@ -1,19 +0,0 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import unittest
import frappe
from frappe.utils import set_request
from frappe.website.serve import get_response
class TestHomepage(unittest.TestCase):
def test_homepage_load(self):
set_request(method="GET", path="home")
response = get_response()
self.assertEqual(response.status_code, 200)
html = frappe.safe_decode(response.get_data())
self.assertTrue('<section class="hero-section' in html)

View File

@ -1,6 +0,0 @@
// Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
// For license information, please see license.txt
frappe.ui.form.on('Homepage Section', {
});

View File

@ -1,336 +0,0 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 1,
"autoname": "Prompt",
"beta": 0,
"creation": "2019-02-10 19:42:35.809238",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_based_on",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Section Based On",
"length": 0,
"no_copy": 0,
"options": "Cards\nCustom HTML",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:doc.section_based_on === 'Cards'",
"fieldname": "section_cards_section",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Section Cards",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"fieldname": "section_cards",
"fieldtype": "Table",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Section Cards",
"length": 0,
"no_copy": 0,
"options": "Homepage Section Card",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"default": "3",
"depends_on": "",
"description": "Number of columns for this section. 3 cards will be shown per row if you select 3 columns.",
"fieldname": "no_of_columns",
"fieldtype": "Select",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Number of Columns",
"length": 0,
"no_copy": 0,
"options": "1\n2\n3\n4\n6",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"collapsible_depends_on": "",
"columns": 0,
"depends_on": "eval:doc.section_based_on === 'Custom HTML'",
"fieldname": "custom_html_section",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Custom HTML",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"depends_on": "",
"description": "Use this field to render any custom HTML in the section.",
"fieldname": "section_html",
"fieldtype": "Code",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Section HTML",
"length": 0,
"no_copy": 0,
"options": "HTML",
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "section_break_7",
"fieldtype": "Section Break",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"description": "Order in which sections should appear. 0 is first, 1 is second and so on.",
"fieldname": "section_order",
"fieldtype": "Int",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Section Order",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 0,
"max_attachments": 0,
"modified": "2019-03-04 23:52:31.290468",
"modified_by": "Administrator",
"module": "Portal",
"name": "Homepage Section",
"name_case": "",
"owner": "Administrator",
"permissions": [
{
"amend": 0,
"cancel": 0,
"create": 1,
"delete": 1,
"email": 1,
"export": 1,
"if_owner": 0,
"import": 0,
"permlevel": 0,
"print": 1,
"read": 1,
"report": 1,
"role": "System Manager",
"set_user_permissions": 0,
"share": 1,
"submit": 0,
"write": 1
}
],
"quick_entry": 0,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}

View File

@ -1,31 +0,0 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from frappe.model.document import Document
from frappe.utils import cint
class HomepageSection(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
from erpnext.portal.doctype.homepage_section_card.homepage_section_card import (
HomepageSectionCard,
)
no_of_columns: DF.Literal["1", "2", "3", "4", "6"]
section_based_on: DF.Literal["Cards", "Custom HTML"]
section_cards: DF.Table[HomepageSectionCard]
section_html: DF.Code | None
section_order: DF.Int
# end: auto-generated types
@property
def column_value(self):
return cint(12 / cint(self.no_of_columns or 3))

View File

@ -1,38 +0,0 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and Contributors
# See license.txt
import unittest
import frappe
from bs4 import BeautifulSoup
from frappe.utils import set_request
from frappe.website.serve import get_response
class TestHomepageSection(unittest.TestCase):
def test_homepage_section_custom_html(self):
frappe.get_doc(
{
"doctype": "Homepage Section",
"name": "Custom HTML Section",
"section_based_on": "Custom HTML",
"section_html": '<div class="custom-section">My custom html</div>',
}
).insert()
set_request(method="GET", path="home")
response = get_response()
self.assertEqual(response.status_code, 200)
html = frappe.safe_decode(response.get_data())
soup = BeautifulSoup(html, "html.parser")
sections = soup.find("main").find_all(class_="custom-section")
self.assertEqual(len(sections), 1)
homepage_section = sections[0]
self.assertEqual(homepage_section.text, "My custom html")
# cleanup
frappe.db.rollback()

View File

@ -1,203 +0,0 @@
{
"allow_copy": 0,
"allow_events_in_timeline": 0,
"allow_guest_to_view": 0,
"allow_import": 0,
"allow_rename": 0,
"beta": 0,
"creation": "2019-02-10 19:39:02.734686",
"custom": 0,
"docstatus": 0,
"doctype": "DocType",
"document_type": "",
"editable_grid": 1,
"engine": "InnoDB",
"fields": [
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "title",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Title",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 1,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "subtitle",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Subtitle",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "image",
"fieldtype": "Attach Image",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Image",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "content",
"fieldtype": "Text",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 0,
"in_standard_filter": 0,
"label": "Content",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
},
{
"allow_bulk_edit": 0,
"allow_in_quick_entry": 0,
"allow_on_submit": 0,
"bold": 0,
"collapsible": 0,
"columns": 0,
"fieldname": "route",
"fieldtype": "Data",
"hidden": 0,
"ignore_user_permissions": 0,
"ignore_xss_filter": 0,
"in_filter": 0,
"in_global_search": 0,
"in_list_view": 1,
"in_standard_filter": 0,
"label": "Route",
"length": 0,
"no_copy": 0,
"permlevel": 0,
"precision": "",
"print_hide": 0,
"print_hide_if_no_value": 0,
"read_only": 0,
"remember_last_selected_value": 0,
"report_hide": 0,
"reqd": 0,
"search_index": 0,
"set_only_once": 0,
"translatable": 0,
"unique": 0
}
],
"has_web_view": 0,
"hide_heading": 0,
"hide_toolbar": 0,
"idx": 0,
"image_view": 0,
"in_create": 0,
"is_submittable": 0,
"issingle": 0,
"istable": 1,
"max_attachments": 0,
"modified": "2019-02-10 20:11:41.040716",
"modified_by": "Administrator",
"module": "Portal",
"name": "Homepage Section Card",
"name_case": "",
"owner": "Administrator",
"permissions": [],
"quick_entry": 1,
"read_only": 0,
"read_only_onload": 0,
"show_name_in_global_search": 0,
"sort_field": "modified",
"sort_order": "DESC",
"track_changes": 1,
"track_seen": 0,
"track_views": 0
}

View File

@ -1,27 +0,0 @@
# Copyright (c) 2019, Frappe Technologies Pvt. Ltd. and contributors
# For license information, please see license.txt
from frappe.model.document import Document
class HomepageSectionCard(Document):
# begin: auto-generated types
# This code is auto-generated. Do not modify anything in this block.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from frappe.types import DF
content: DF.Text | None
image: DF.AttachImage | None
parent: DF.Data
parentfield: DF.Data
parenttype: DF.Data
route: DF.Data | None
subtitle: DF.Data | None
title: DF.Data
# end: auto-generated types
pass

View File

@ -33,38 +33,6 @@
</div> </div>
{% endmacro %} {% endmacro %}
{% macro render_homepage_section(section) %}
{% if section.section_based_on == 'Custom HTML' and section.section_html %}
{{ section.section_html }}
{% elif section.section_based_on == 'Cards' %}
<section class="container my-5">
<h3>{{ section.name }}</h3>
<div class="row">
{% for card in section.section_cards %}
<div class="col-md-{{ section.column_value }} mb-4">
<div class="card h-100 justify-content-between">
{% if card.image %}
<img class="card-img-top h-75" src="{{ card.image }}" loading="lazy" alt="{{ card.title }}"></img>
{% endif %}
<div class="card-body">
<h5 class="card-title">{{ card.title }}</h5>
<p class="card-subtitle mb-2 text-muted">{{ card.subtitle or '' }}</p>
<p class="card-text">{{ card.content or '' | truncate(140, True) }}</p>
</div>
<div class="card-body flex-grow-0">
<a href="{{ card.route }}" class="card-link">{{ _('More details') }}</a>
</div>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{% endmacro %}
{%- macro item_card(item, is_featured=False, is_full_width=False, align="Left") -%} {%- macro item_card(item, is_featured=False, is_full_width=False, align="Left") -%}
{%- set align_items_class = resolve_class({ {%- set align_items_class = resolve_class({
'align-items-end': align == 'Right', 'align-items-end': align == 'Right',

View File

@ -1,8 +0,0 @@
/* csslint ignore:start */
{% if homepage.hero_image %}
.hero-image {
background-size: cover;
padding: 10rem 0;
}
{% endif %}
/* csslint ignore:end */

View File

@ -1,76 +0,0 @@
{% extends "templates/web.html" %}
{% from "erpnext/templates/includes/macros.html" import render_homepage_section %}
{% block content %}
<main>
{% if homepage.hero_section_based_on == 'Default' %}
<section class="hero-section border-bottom {%if homepage.hero_image%}hero-image{%endif%}"
{% if homepage.hero_image %}
style="background-image: url('{{ homepage.hero_image }}');"
{%- endif %}
>
<div class="container py-5">
<h1 class="d-none d-sm-block display-4">{{ homepage.tag_line }}</h1>
<h1 class="d-block d-sm-none">{{ homepage.tag_line }}</h1>
<h2 class="d-none d-sm-block">{{ homepage.description }}</h2>
<h3 class="d-block d-sm-none">{{ homepage.description }}</h3>
</div>
</section>
{% elif homepage.hero_section_based_on == 'Slideshow' and slideshow %}
<section class="hero-section">
{% include "templates/includes/slideshow.html" %}
</section>
{% elif homepage.hero_section_based_on == 'Homepage Section' %}
{{ render_homepage_section(homepage.hero_section_doc) }}
{% endif %}
{% if homepage.products %}
<section class="container section-products my-5">
<h3>{{ _('Products') }}</h3>
<div class="row">
{% for item in homepage.products %}
<div class="col-md-4 mb-4">
<div class="card h-100 justify-content-between">
<img class="card-img-top website-image-extra-large" src="{{ item.image }}" loading="lazy" alt="{{ item.item_name }}"></img>
<div class="card-body flex-grow-0">
<h5 class="card-title">{{ item.item_name }}</h5>
<a href="{{ item.route }}" class="card-link">{{ _('More details') }}</a>
</div>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{% if blogs %}
<section class="container my-5">
<h3>{{ _('Publications') }}</h3>
<div class="row">
{% for blog in blogs %}
<div class="col-md-4 mb-4">
<div class="card h-100">
<div class="card-body">
<h5 class="card-title">{{ blog.title }}</h5>
<p class="card-subtitle mb-2 text-muted">{{ _('By {0}').format(blog.blogger) }}</p>
<p class="card-text">{{ blog.blog_intro }}</p>
</div>
<div class="card-body flex-grow-0">
<a href="{{ blog.route }}" class="card-link">{{ _('Read blog') }}</a>
</div>
</div>
</div>
{% endfor %}
</div>
</section>
{% endif %}
{% for section in homepage_sections %}
{{ render_homepage_section(section) }}
{% endfor %}
</main>
{% endblock %}

View File

@ -1,49 +0,0 @@
# Copyright (c) 2015, Frappe Technologies Pvt. Ltd. and Contributors
# License: GNU General Public License v3. See license.txt
import frappe
no_cache = 1
def get_context(context):
homepage = frappe.get_cached_doc("Homepage")
homepage.title = homepage.title or homepage.company
context.title = homepage.title
context.homepage = homepage
if homepage.hero_section_based_on == "Homepage Section" and homepage.hero_section:
homepage.hero_section_doc = frappe.get_cached_doc("Homepage Section", homepage.hero_section)
if homepage.slideshow:
doc = frappe.get_cached_doc("Website Slideshow", homepage.slideshow)
context.slideshow = homepage.slideshow
context.slideshow_header = doc.header
context.slides = doc.slideshow_items
context.blogs = frappe.get_all(
"Blog Post",
fields=["title", "blogger", "blog_intro", "route"],
filters={"published": 1},
order_by="modified desc",
limit=3,
)
# filter out homepage section which is used as hero section
homepage_hero_section = (
homepage.hero_section_based_on == "Homepage Section" and homepage.hero_section
)
homepage_sections = frappe.get_all(
"Homepage Section",
filters=[["name", "!=", homepage_hero_section]] if homepage_hero_section else None,
order_by="section_order asc",
)
context.homepage_sections = [
frappe.get_cached_doc("Homepage Section", name) for name in homepage_sections
]
context.metatags = context.metatags or frappe._dict({})
context.metatags.image = homepage.hero_image or None
context.metatags.description = homepage.description or None