diff --git a/frappe/templates/base.html b/frappe/templates/base.html index 2420d64843..ce0dc11160 100644 --- a/frappe/templates/base.html +++ b/frappe/templates/base.html @@ -35,7 +35,7 @@ {%- for link in web_include_js %} {%- endfor -%} - {%- block head_include %}{% endblock -%} + {%- block head_include %}{{ head_include or "" }}{% endblock -%} {%- endblock -%} @@ -97,5 +97,6 @@ {%- if script_lib is defined -%}{{ script_lib }}{%- endif -%} {%- endblock -%} + {%- block body_include %}{{ body_include or "" }}{% endblock -%} diff --git a/frappe/templates/includes/full_index.html b/frappe/templates/includes/full_index.html new file mode 100644 index 0000000000..882c4e1fd5 --- /dev/null +++ b/frappe/templates/includes/full_index.html @@ -0,0 +1,12 @@ +{% macro make_item_list(item_list) %} +
    + {% for item in item_list %} +
  1. + {{ item.title }} + {% if item.children %}{{ make_item_list(item.children) }}{% endif %} +
  2. + {% endfor %} +
+{% endmacro %} + +{{ make_item_list(full_index) }} diff --git a/frappe/templates/includes/list/list.html b/frappe/templates/includes/list/list.html index ce361381d2..3495045220 100644 --- a/frappe/templates/includes/list/list.html +++ b/frappe/templates/includes/list/list.html @@ -1,7 +1,8 @@ +
- {% if not hide_filters -%} - {% include "templates/includes/list/filters.html" %} - {%- endif %} +
{% for item in result %} diff --git a/frappe/templates/includes/list/row_template.html b/frappe/templates/includes/list/row_template.html index 37c935714f..65fa99305c 100644 --- a/frappe/templates/includes/list/row_template.html +++ b/frappe/templates/includes/list/row_template.html @@ -1,21 +1,7 @@ {% set doc = frappe.get_doc(doc) %} {% set subject = doc.get(meta.title_field or "name") %} - -
-
-
-
{{ subject }}
-
- {{ doc.status or "" }} -
-
-
- {% if subject != doc.name %} -
- {{ doc.name }} -
- {% endif %} -
- {{ frappe.utils.pretty_date(doc.creation) }}
+
- diff --git a/frappe/templates/pages/list.html b/frappe/templates/pages/list.html index f99f1ba085..ff75167fa1 100644 --- a/frappe/templates/pages/list.html +++ b/frappe/templates/pages/list.html @@ -1,6 +1,16 @@ {% block title %}{{ title or (_("{0} List").format(_(doctype))) }}{% endblock %} -{% block header %}

{{ title or (_("{0} List").format(_(doctype))) }}

{% endblock %} +{% block header %} + {% if default_subtitle %} +
+

+ {{ default_subtitle }} +

+
+ {% else %} +

{{ title or (_("{0} List").format(_(doctype))) }}

+ {% endif %} +{% endblock %} {% block content %}{% include "templates/includes/list/list.html" %}{% endblock %} diff --git a/frappe/templates/pages/list.py b/frappe/templates/pages/list.py index 062a250a53..42dfe8f08e 100644 --- a/frappe/templates/pages/list.py +++ b/frappe/templates/pages/list.py @@ -5,6 +5,7 @@ from __future__ import unicode_literals import frappe from frappe.utils import cint from frappe.website.render import resolve_path +from frappe import _ no_cache = 1 no_sitemap = 1 @@ -54,6 +55,9 @@ def get(doctype, txt=None, limit_start=0, **kwargs): show_more = (_get_list(doctype=doctype, txt=txt, filters=filters, limit_start=next_start, limit_page_length=1) and True or False) + if txt: + list_context.default_subtitle = _('Filtered by "{0}"').format(txt) + result = [] row_template = list_context.row_template or "templates/includes/list/row_template.html" for doc in raw_result: @@ -95,7 +99,7 @@ def get_list(doctype, txt, filters, limit_start, limit_page_length=20, ignore_pe else: filters.append([doctype, "name", "like", "%" + txt + "%"]) - return frappe.get_list(doctype, fields = ["*"], + return frappe.get_list(doctype, fields = "distinct *", filters=filters, or_filters=or_filters, limit_start=limit_start, limit_page_length = limit_page_length, ignore_permissions=ignore_permissions) diff --git a/frappe/website/doctype/web_page/web_page.json b/frappe/website/doctype/web_page/web_page.json index f4823b1eff..fa738d67f3 100644 --- a/frappe/website/doctype/web_page/web_page.json +++ b/frappe/website/doctype/web_page/web_page.json @@ -200,7 +200,7 @@ "icon": "icon-file-alt", "idx": 1, "max_attachments": 20, - "modified": "2015-02-20 08:30:53.345780", + "modified": "2015-03-23 17:57:49.375385", "modified_by": "Administrator", "module": "Website", "name": "Web Page", @@ -221,5 +221,6 @@ "write": 1 } ], + "search_fields": "title,main_section", "title_field": "title" } \ No newline at end of file diff --git a/frappe/website/doctype/web_page/web_page.py b/frappe/website/doctype/web_page/web_page.py index 5fe4664e9b..4c0a144cfe 100644 --- a/frappe/website/doctype/web_page/web_page.py +++ b/frappe/website/doctype/web_page/web_page.py @@ -11,6 +11,7 @@ from frappe.website.utils import find_first_image, get_comment_list from markdown2 import markdown from frappe.utils.jinja import render_template from jinja2.exceptions import TemplateSyntaxError +from frappe import _ class WebPage(WebsiteGenerator): save_versions = True @@ -147,6 +148,22 @@ class WebPage(WebsiteGenerator): if image: context.metatags["image"] = image +# def get_list_context(context=None): +# list_context = frappe._dict( +# title = _("Website Search"), +# template = "templates/includes/kb_list.html", +# row_template = "templates/includes/kb_row.html", +# get_level_class = get_level_class, +# hide_filters = True, +# filters = {"published": 1} +# ) +# +# if frappe.local.form_dict.txt: +# list_context.subtitle = _('Filtered by "{0}"').format(frappe.local.form_dict.txt) +# # +# # list_context.update(frappe.get_doc("Blog Settings", "Blog Settings").as_dict()) +# return list_context + def check_broken_links(): cnt = 0 for p in frappe.db.sql("select name, main_section from `tabWeb Page`", as_dict=True): diff --git a/frappe/website/js/website.js b/frappe/website/js/website.js index d893ca25e9..329cb777a0 100644 --- a/frappe/website/js/website.js +++ b/frappe/website/js/website.js @@ -440,12 +440,15 @@ $.extend(frappe, { var val = $(this).val(); if(e.which===13 && val) { $(this).val("").blur(); - var path = (frappe.search_path && frappe.search_path[location.pathname] || location.pathname); - frappe.load_via_ajax(path + "?txt=" + encodeURIComponent(val)); + frappe.do_search(val); return false; } }); }, + do_search: function(val) { + var path = (frappe.search_path && frappe.search_path[location.pathname] || location.pathname); + frappe.load_via_ajax(path + "?txt=" + encodeURIComponent(val)); + }, set_search_path: function(path) { frappe.search_path[location.pathname] = path; }, diff --git a/frappe/website/template.py b/frappe/website/template.py index c9eba456a7..ec82c7eb02 100644 --- a/frappe/website/template.py +++ b/frappe/website/template.py @@ -122,7 +122,6 @@ def add_index(out, context): html = ('


'+_("Next")+': {title}

').format(**next_item) out["content"] = out["content"].replace("{next}", html) - def add_hero(out, context): """Add a hero element if specified in content or hooks. Hero elements get full page width.""" diff --git a/frappe/website/utils.py b/frappe/website/utils.py index 42a47ce1c9..100edc33c9 100644 --- a/frappe/website/utils.py +++ b/frappe/website/utils.py @@ -2,7 +2,7 @@ # MIT License. See license.txt from __future__ import unicode_literals -import frappe, re +import frappe, re, os def delete_page_cache(path): if not path: @@ -162,3 +162,21 @@ def with_leading_slash(path): path = "/" + path return path + +def get_full_index(doctype="Web Page"): + """Returns full index of the website (on Web Page) upto the n-th level""" + all_routes = [] + + def get_children(parent): + children = frappe.db.get_all(doctype, ["parent_website_route", "page_name", "title"], + {"parent_website_route": parent}, order_by="idx asc") + for d in children: + d.url = with_leading_slash(os.path.join(d.parent_website_route or "", d.page_name)) + if d.url not in all_routes: + d.children = get_children(d.url[1:]) + all_routes.append(d.url) + + return children + + return get_children("") +