@@ -1,7 +1,10 @@ | |||||
{% if parents and parents|length > 0 %} | {% if parents and parents|length > 0 %} | ||||
<ul class="breadcrumb"> | <ul class="breadcrumb"> | ||||
<li><a href="{{ parents[-1].name }}"><span class="icon icon-angle-left"></span> | |||||
{{ parents[-1].page_title or parents[-1].title or "" }}</a></li> | |||||
<li> | |||||
<span class="icon icon-angle-left"></span> | |||||
<a href="{{ parents[-1].name | with_leading_slash }}"> | |||||
{{ parents[-1].page_title or parents[-1].title or "" }}</a> | |||||
</li> | |||||
{# | {# | ||||
<!-- {% for parent in parents %} | <!-- {% for parent in parents %} | ||||
<li><a href="{{ parent.name }}">{{ parent.page_title or parent.title or "" }}</a></li> | <li><a href="{{ parent.name }}">{{ parent.page_title or parent.title or "" }}</a></li> | ||||
@@ -10,7 +10,7 @@ from werkzeug.wrappers import Response | |||||
from werkzeug.routing import Map, Rule, NotFound | from werkzeug.routing import Map, Rule, NotFound | ||||
from frappe.website.context import get_context | from frappe.website.context import get_context | ||||
from frappe.website.utils import scrub_relative_urls, get_home_page, can_cache, delete_page_cache | |||||
from frappe.website.utils import get_home_page, can_cache, delete_page_cache | |||||
from frappe.website.router import clear_sitemap | from frappe.website.router import clear_sitemap | ||||
class PageNotFoundError(Exception): pass | class PageNotFoundError(Exception): pass | ||||
@@ -6,7 +6,6 @@ import frappe | |||||
from frappe.utils import strip_html | from frappe.utils import strip_html | ||||
from frappe import _ | from frappe import _ | ||||
from frappe.website.utils import scrub_relative_urls | |||||
from jinja2.utils import concat | from jinja2.utils import concat | ||||
from jinja2 import meta | from jinja2 import meta | ||||
import re | import re | ||||
@@ -49,7 +48,7 @@ def render_blocks(template_path, out, context): | |||||
template = frappe.get_template(template_path) | template = frappe.get_template(template_path) | ||||
for block, render in template.blocks.items(): | for block, render in template.blocks.items(): | ||||
new_context = template.new_context(context) | new_context = template.new_context(context) | ||||
out[block] = scrub_relative_urls(concat(render(new_context))) | |||||
out[block] = concat(render(new_context)) | |||||
def separate_style_and_script(out, context): | def separate_style_and_script(out, context): | ||||
"""Extract `style` and `script` tags into separate blocks""" | """Extract `style` and `script` tags into separate blocks""" | ||||
@@ -62,8 +61,7 @@ def set_breadcrumbs(out, context): | |||||
# breadcrumbs | # breadcrumbs | ||||
if not out["no_breadcrumbs"] and "breadcrumbs" not in out: | if not out["no_breadcrumbs"] and "breadcrumbs" not in out: | ||||
out["breadcrumbs"] = scrub_relative_urls( | |||||
frappe.get_template("templates/includes/breadcrumbs.html").render(context)) | |||||
out["breadcrumbs"] = frappe.get_template("templates/includes/breadcrumbs.html").render(context) | |||||
def set_title_and_header(out, context): | def set_title_and_header(out, context): | ||||
"""Extract and set title and header from content or context.""" | """Extract and set title and header from content or context.""" | ||||
@@ -12,12 +12,6 @@ def delete_page_cache(path): | |||||
cache.delete_keys("page_context:" + path) | cache.delete_keys("page_context:" + path) | ||||
cache.delete_keys("sitemap_options:" + path) | cache.delete_keys("sitemap_options:" + path) | ||||
def scrub_relative_urls(html): | |||||
"""prepend a slash before a relative url""" | |||||
html = re.sub("""(src|href)[^\w'"]*['"](?!http|ftp|mailto|/|#|%|{)([^'" >]+)['"]""", '\g<1> = "/\g<2>"', html) | |||||
html = re.sub("""url\((?!(['"]?)(http|ftp|/|#|%|{))(['"]?)([^\(\)]+)\)""", 'url(\g<3>/\g<4>)', html) | |||||
return html | |||||
def find_first_image(html): | def find_first_image(html): | ||||
m = re.finditer("""<img[^>]*src\s?=\s?['"]([^'"]*)['"]""", html) | m = re.finditer("""<img[^>]*src\s?=\s?['"]([^'"]*)['"]""", html) | ||||
try: | try: | ||||