fix(ux): add better home for blog category, cleanup forms
This commit is contained in:
parent
38686d44fb
commit
2a50d6c593
8 changed files with 170 additions and 76 deletions
|
|
@ -8,9 +8,12 @@
|
|||
"document_type": "Setup",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"title",
|
||||
"published",
|
||||
"route"
|
||||
"title",
|
||||
"description",
|
||||
"column_break_4",
|
||||
"route",
|
||||
"preview_image"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -35,6 +38,20 @@
|
|||
"label": "Route",
|
||||
"read_only": 1,
|
||||
"unique": 1
|
||||
},
|
||||
{
|
||||
"fieldname": "description",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Description"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_4",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "preview_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"label": "Preview Image"
|
||||
}
|
||||
],
|
||||
"has_web_view": 1,
|
||||
|
|
@ -42,8 +59,15 @@
|
|||
"idx": 1,
|
||||
"index_web_pages_for_search": 1,
|
||||
"is_published_field": "published",
|
||||
"links": [],
|
||||
"modified": "2020-09-29 10:48:36.886753",
|
||||
"links": [
|
||||
{
|
||||
"group": "Posts",
|
||||
"link_doctype": "Blog Post",
|
||||
"link_fieldname": "blog_category"
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2022-10-18 15:43:39.789982",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Blog Category",
|
||||
|
|
@ -71,6 +95,7 @@
|
|||
"quick_entry": 1,
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "title",
|
||||
"track_changes": 1
|
||||
}
|
||||
|
|
@ -94,11 +94,11 @@
|
|||
"label": "Blog Intro"
|
||||
},
|
||||
{
|
||||
"default": "Rich Text",
|
||||
"default": "Markdown",
|
||||
"fieldname": "content_type",
|
||||
"fieldtype": "Select",
|
||||
"label": "Content Type",
|
||||
"options": "Rich Text\nMarkdown\nHTML",
|
||||
"options": "Markdown\nRich Text\nHTML",
|
||||
"reqd": 1
|
||||
},
|
||||
{
|
||||
|
|
@ -215,7 +215,7 @@
|
|||
"is_published_field": "published",
|
||||
"links": [],
|
||||
"make_attachments_public": 1,
|
||||
"modified": "2022-08-24 07:10:08.620136",
|
||||
"modified": "2022-10-18 10:09:10.550734",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Blog Post",
|
||||
|
|
|
|||
|
|
@ -204,13 +204,19 @@ def get_list_context(context=None):
|
|||
title=_("Blog"),
|
||||
)
|
||||
|
||||
category = frappe.utils.escape_html(
|
||||
blog_settings = frappe.get_doc("Blog Settings").as_dict(no_default_fields=True)
|
||||
list_context.update(blog_settings)
|
||||
|
||||
category_name = frappe.utils.escape_html(
|
||||
frappe.local.form_dict.blog_category or frappe.local.form_dict.category
|
||||
)
|
||||
if category:
|
||||
category_title = get_blog_category(category)
|
||||
list_context.sub_title = _("Posts filed under {0}").format(category_title)
|
||||
list_context.title = category_title
|
||||
if category_name:
|
||||
category = frappe.get_doc("Blog Category", category_name)
|
||||
list_context.blog_introduction = category.description or _("Posts filed under {0}").format(
|
||||
category.title
|
||||
)
|
||||
list_context.blog_title = category.title
|
||||
list_context.preview_image = category.preview_image
|
||||
|
||||
elif frappe.local.form_dict.blogger:
|
||||
blogger = frappe.db.get_value("Blogger", {"name": frappe.local.form_dict.blogger}, "full_name")
|
||||
|
|
@ -225,12 +231,16 @@ def get_list_context(context=None):
|
|||
else:
|
||||
list_context.parents = [{"name": _("Home"), "route": "/"}]
|
||||
|
||||
blog_settings = frappe.get_doc("Blog Settings").as_dict(no_default_fields=True)
|
||||
list_context.update(blog_settings)
|
||||
|
||||
if blog_settings.browse_by_category:
|
||||
list_context.blog_categories = get_blog_categories()
|
||||
|
||||
list_context.metatags = {
|
||||
"name": list_context.blog_title,
|
||||
"title": list_context.blog_title,
|
||||
"description": list_context.blog_introduction,
|
||||
"image": list_context.preview_image,
|
||||
}
|
||||
|
||||
return list_context
|
||||
|
||||
|
||||
|
|
@ -265,10 +275,6 @@ def clear_blog_cache():
|
|||
clear_cache("writers")
|
||||
|
||||
|
||||
def get_blog_category(route):
|
||||
return frappe.db.get_value("Blog Category", {"name": route}, "title") or route
|
||||
|
||||
|
||||
def get_blog_list(
|
||||
doctype, txt=None, filters=None, limit_start=0, limit_page_length=20, order_by=None
|
||||
):
|
||||
|
|
|
|||
|
|
@ -12,29 +12,30 @@
|
|||
<p>{{ blog_introduction or '' }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 align-self-end">
|
||||
|
||||
{%- if browse_by_category -%}
|
||||
<label for="category-select" class="sr-only">{{ _("Browse by category") }}</label>
|
||||
<select id="category-select" class="custom-select" onchange="window.location.pathname = this.value">
|
||||
<option value="" {{ not frappe.form_dict.category and "selected" or "" }} disabled>
|
||||
{{ _("Browse by category") }}
|
||||
</option>
|
||||
{%- if frappe.form_dict.category -%}
|
||||
<option value="blog">{{ _("Show all blogs") }}</option>
|
||||
{%- endif -%}
|
||||
{%- for category in blog_categories -%}
|
||||
<option value="{{ category.route }}" {{ frappe.form_dict.category == category.name and "selected" or "" }}>
|
||||
{{ _(category.title) }}
|
||||
</option>
|
||||
{%- endfor -%}
|
||||
</select>
|
||||
<div style="max-width: 20rem">
|
||||
<label for="category-select" class="sr-only">{{ _("Browse by category") }}</label>
|
||||
<select id="category-select" class="custom-select" onchange="window.location.pathname = this.value">
|
||||
<option value="" {{ not frappe.form_dict.category and "selected" or "" }} disabled>
|
||||
{{ _("Browse by category") }}
|
||||
</option>
|
||||
{%- if frappe.form_dict.category -%}
|
||||
<option value="blog">{{ _("Show all blogs") }}</option>
|
||||
{%- endif -%}
|
||||
{%- for category in blog_categories -%}
|
||||
<option value="{{ category.route }}" {{ frappe.form_dict.category == category.name and "selected" or "" }}>
|
||||
{{ _(category.title) }}
|
||||
</option>
|
||||
{%- endfor -%}
|
||||
</select>
|
||||
</div>
|
||||
{%- endif -%}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="blog-list-content">
|
||||
<div class="website-list" data-doctype="{{ doctype }}" data-txt="{{ txt or '[notxt]' | e }}">
|
||||
<div data-doctype="{{ doctype }}" data-txt="{{ txt or '[notxt]' | e }}">
|
||||
{% if not result -%}
|
||||
<div class="text-muted" style="min-height: 300px;">
|
||||
{{ no_result_message or _("Nothing to show") }}
|
||||
|
|
@ -54,10 +55,10 @@
|
|||
{% block script %}
|
||||
<script>
|
||||
frappe.ready(() => {
|
||||
let result_wrapper = $(".website-list .result");
|
||||
let result_wrapper = $(".blog-list.result");
|
||||
let next_start = {{ next_start or 0 }};
|
||||
|
||||
$(".website-list .btn-more").on("click", function() {
|
||||
$(".blog-list-content .btn-more").on("click", function() {
|
||||
let $btn = $(this);
|
||||
let args = $.extend(frappe.utils.get_query_params(), {
|
||||
doctype: "Blog Post",
|
||||
|
|
@ -82,7 +83,7 @@
|
|||
|
||||
function toggle_more(show) {
|
||||
if (!show) {
|
||||
$(".website-list .more-block").addClass("hide");
|
||||
$(".btn-more").addClass("hide");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -7,11 +7,12 @@
|
|||
"field_order": [
|
||||
"blog_title",
|
||||
"blog_introduction",
|
||||
"preview_image",
|
||||
"column_break",
|
||||
"enable_social_sharing",
|
||||
"show_cta_in_blog",
|
||||
"allow_guest_to_comment",
|
||||
"browse_by_category",
|
||||
"show_cta_in_blog",
|
||||
"cta_section",
|
||||
"title",
|
||||
"subtitle",
|
||||
|
|
@ -49,13 +50,13 @@
|
|||
"default": "0",
|
||||
"fieldname": "show_cta_in_blog",
|
||||
"fieldtype": "Check",
|
||||
"label": "Show CTA in Blog"
|
||||
"label": "Show \"Call to Action\" in Blog"
|
||||
},
|
||||
{
|
||||
"depends_on": "eval:doc.show_cta_in_blog",
|
||||
"fieldname": "cta_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "CTA"
|
||||
"label": "Call to Action"
|
||||
},
|
||||
{
|
||||
"fieldname": "title",
|
||||
|
|
@ -87,7 +88,8 @@
|
|||
},
|
||||
{
|
||||
"fieldname": "section_break_12",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Rate Limits"
|
||||
},
|
||||
{
|
||||
"default": "5",
|
||||
|
|
@ -118,13 +120,18 @@
|
|||
"fieldname": "like_limit",
|
||||
"fieldtype": "Int",
|
||||
"label": "Like limit"
|
||||
},
|
||||
{
|
||||
"fieldname": "preview_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"label": "Preview Image"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-cog",
|
||||
"idx": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-07-12 17:45:49.108398",
|
||||
"modified": "2022-10-18 15:01:36.202010",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Blog Settings",
|
||||
|
|
|
|||
|
|
@ -63,11 +63,13 @@
|
|||
"link_fieldname": "blogger"
|
||||
}
|
||||
],
|
||||
"make_attachments_public": 1,
|
||||
"max_attachments": 1,
|
||||
"modified": "2020-05-28 19:22:40.959895",
|
||||
"modified": "2022-10-18 15:44:31.473178",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Blogger",
|
||||
"naming_rule": "By fieldname",
|
||||
"owner": "Administrator",
|
||||
"permissions": [
|
||||
{
|
||||
|
|
@ -95,6 +97,7 @@
|
|||
],
|
||||
"sort_field": "modified",
|
||||
"sort_order": "DESC",
|
||||
"states": [],
|
||||
"title_field": "full_name",
|
||||
"track_changes": 1
|
||||
}
|
||||
|
|
@ -11,14 +11,21 @@
|
|||
"document_type": "Other",
|
||||
"engine": "InnoDB",
|
||||
"field_order": [
|
||||
"home_tab",
|
||||
"sb0",
|
||||
"home_page",
|
||||
"cb4",
|
||||
"title_prefix",
|
||||
"misc_section",
|
||||
"app_name",
|
||||
"disable_signup",
|
||||
"column_break_9",
|
||||
"app_logo",
|
||||
"section_break_6",
|
||||
"website_theme",
|
||||
"website_theme_image",
|
||||
"website_theme_image_link",
|
||||
"navbar_tab",
|
||||
"brand",
|
||||
"banner_image",
|
||||
"splash_image",
|
||||
|
|
@ -38,17 +45,22 @@
|
|||
"call_to_action_url",
|
||||
"banner",
|
||||
"banner_html",
|
||||
"footer_tab",
|
||||
"footer",
|
||||
"footer_logo",
|
||||
"copyright",
|
||||
"address",
|
||||
"footer_items",
|
||||
"footer_details_section",
|
||||
"hide_footer_signup",
|
||||
"copyright",
|
||||
"footer_logo",
|
||||
"column_break_37",
|
||||
"address",
|
||||
"footer_powered",
|
||||
"custom_footer_section",
|
||||
"footer_template",
|
||||
"footer_template_values",
|
||||
"edit_footer_template_values",
|
||||
"hide_footer_signup",
|
||||
"integrations",
|
||||
"analytics_section",
|
||||
"enable_view_tracking",
|
||||
"enable_google_indexing",
|
||||
"authorize_api_indexing_access",
|
||||
|
|
@ -57,18 +69,15 @@
|
|||
"column_break_17",
|
||||
"google_analytics_id",
|
||||
"google_analytics_anonymize_ip",
|
||||
"misc_section",
|
||||
"app_name",
|
||||
"app_logo",
|
||||
"disable_signup",
|
||||
"account_deletion_settings_section",
|
||||
"auto_account_deletion",
|
||||
"show_account_deletion_link",
|
||||
"section_break_38",
|
||||
"subdomain",
|
||||
"head_html",
|
||||
"robots_txt",
|
||||
"route_redirects",
|
||||
"account_deletion_settings_section",
|
||||
"show_account_deletion_link",
|
||||
"auto_account_deletion"
|
||||
"redirects_tab",
|
||||
"route_redirects"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
|
|
@ -96,7 +105,8 @@
|
|||
},
|
||||
{
|
||||
"fieldname": "section_break_6",
|
||||
"fieldtype": "Section Break"
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Theme"
|
||||
},
|
||||
{
|
||||
"default": "Standard",
|
||||
|
|
@ -143,7 +153,6 @@
|
|||
"label": "Set Banner from Image"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "top_bar",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Navbar"
|
||||
|
|
@ -175,11 +184,10 @@
|
|||
"options": "HTML"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"collapsible_depends_on": "footer_items",
|
||||
"fieldname": "footer",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Footer"
|
||||
"label": "Footer Items"
|
||||
},
|
||||
{
|
||||
"fieldname": "copyright",
|
||||
|
|
@ -189,7 +197,7 @@
|
|||
{
|
||||
"description": "Address and other legal information you may want to put in the footer.",
|
||||
"fieldname": "address",
|
||||
"fieldtype": "Text Editor",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Address",
|
||||
"max_height": "8rem"
|
||||
},
|
||||
|
|
@ -208,7 +216,7 @@
|
|||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "integrations",
|
||||
"fieldtype": "Section Break",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Integrations"
|
||||
},
|
||||
{
|
||||
|
|
@ -221,7 +229,6 @@
|
|||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "misc_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Login Page"
|
||||
|
|
@ -249,8 +256,8 @@
|
|||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "section_break_38",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "HTML Header, Robots and Redirects"
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Header, Robots"
|
||||
},
|
||||
{
|
||||
"description": "Added HTML in the <head> section of the web page, primarily used for website verification and SEO",
|
||||
|
|
@ -393,7 +400,6 @@
|
|||
"label": "App Logo"
|
||||
},
|
||||
{
|
||||
"collapsible": 1,
|
||||
"fieldname": "account_deletion_settings_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Account Deletion Settings"
|
||||
|
|
@ -413,12 +419,56 @@
|
|||
{
|
||||
"fieldname": "footer_powered",
|
||||
"fieldtype": "Small Text",
|
||||
"label": "Footer \"Powered By\""
|
||||
"label": "Footer \"Powered By\"",
|
||||
"max_height": "2rem"
|
||||
},
|
||||
{
|
||||
"fieldname": "splash_image",
|
||||
"fieldtype": "Attach Image",
|
||||
"label": "Splash Image"
|
||||
},
|
||||
{
|
||||
"fieldname": "home_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Home"
|
||||
},
|
||||
{
|
||||
"fieldname": "navbar_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Navbar"
|
||||
},
|
||||
{
|
||||
"fieldname": "footer_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Footer"
|
||||
},
|
||||
{
|
||||
"fieldname": "footer_details_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Footer Details"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_37",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "custom_footer_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Custom Footer"
|
||||
},
|
||||
{
|
||||
"fieldname": "redirects_tab",
|
||||
"fieldtype": "Tab Break",
|
||||
"label": "Redirects"
|
||||
},
|
||||
{
|
||||
"fieldname": "column_break_9",
|
||||
"fieldtype": "Column Break"
|
||||
},
|
||||
{
|
||||
"fieldname": "analytics_section",
|
||||
"fieldtype": "Section Break",
|
||||
"label": "Analytics"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-cog",
|
||||
|
|
@ -426,7 +476,7 @@
|
|||
"index_web_pages_for_search": 1,
|
||||
"issingle": 1,
|
||||
"links": [],
|
||||
"modified": "2022-05-27 12:33:29.019998",
|
||||
"modified": "2022-10-18 09:50:24.621839",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Website",
|
||||
"name": "Website Settings",
|
||||
|
|
@ -451,4 +501,4 @@
|
|||
"sort_order": "ASC",
|
||||
"states": [],
|
||||
"track_changes": 1
|
||||
}
|
||||
}
|
||||
|
|
@ -123,13 +123,15 @@ def resolve_redirect(path, query_string=None):
|
|||
path_to_match = path + "?" + frappe.safe_decode(query_string)
|
||||
|
||||
try:
|
||||
if re.match(pattern, path_to_match):
|
||||
redirect_to = re.sub(pattern, rule["target"], path_to_match)
|
||||
frappe.flags.redirect_location = redirect_to
|
||||
frappe.cache().hset("website_redirects", path_to_match, redirect_to)
|
||||
raise frappe.Redirect
|
||||
match = re.match(pattern, path_to_match)
|
||||
except re.error as e:
|
||||
frappe.log_error("Broken Redirect")
|
||||
frappe.log_error("Broken Redirect: " + pattern)
|
||||
|
||||
if match:
|
||||
redirect_to = re.sub(pattern, rule["target"], path_to_match)
|
||||
frappe.flags.redirect_location = redirect_to
|
||||
frappe.cache().hset("website_redirects", path_to_match, redirect_to)
|
||||
raise frappe.Redirect
|
||||
|
||||
|
||||
def resolve_path(path):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue