コード例 #1
0
ファイル: router.py プロジェクト: drukhil/frappe
def make_toc(context, out):
	'''Insert full index (table of contents) for {index} tag'''
	from frappe.website.utils import get_full_index
	if '{index}' in out:
		html = frappe.get_template("templates/includes/full_index.html").render({
			"full_index": get_full_index(),
			"url_prefix": context.url_prefix or "/",
			"route": context.route
		})

		out = out.replace('{index}', html)

	if '{next}' in out:
		# insert next link
		next_item = None
		children_map = get_full_index()
		parent_route = os.path.dirname(context.route)
		children = children_map[parent_route]

		if parent_route and children:
			for i, c in enumerate(children):
				if c.route == context.route and i < (len(children) - 1):
					next_item = children[i+1]
					next_item.url_prefix = context.url_prefix or "/"

		if next_item:
			if next_item.route and next_item.title:
				html = ('<p class="btn-next-wrapper">'+_("Next")\
					+': <a class="btn-next" href="{url_prefix}{route}">{title}</a></p>').format(**next_item)

				out = out.replace('{next}', html)

	return out
コード例 #2
0
ファイル: router.py プロジェクト: nikunj1222/frappe7
def make_toc(context, out):
	'''Insert full index (table of contents) for {index} tag'''
	from frappe.website.utils import get_full_index
	if '{index}' in out:
		html = frappe.get_template("templates/includes/full_index.html").render({
			"full_index": get_full_index(),
			"url_prefix": context.url_prefix or "/",
			"route": context.route
		})

		out = out.replace('{index}', html)

	if '{next}' in out:
		# insert next link
		next_item = None
		children_map = get_full_index()
		parent_route = os.path.dirname(context.route)
		children = children_map[parent_route]

		if parent_route and children:
			for i, c in enumerate(children):
				if c.route == context.route and i < (len(children) - 1):
					next_item = children[i+1]
					next_item.url_prefix = context.url_prefix or "/"

		if next_item:
			if next_item.route and next_item.title:
				html = ('<p class="btn-next-wrapper">'+_("Next")\
					+': <a class="btn-next" href="{url_prefix}{route}">{title}</a></p>').format(**next_item)

				out = out.replace('{next}', html)

	return out
コード例 #3
0
ファイル: template.py プロジェクト: shiv09/frappe
def add_index(out, context):
	"""Add index, next button if `{index}`, `{next}` is present."""
	# table of contents

	extn = ""
	if context.page_links_with_extn:
		extn = ".html"

	if "{index}" in out.get("content", "") and context.get("children"):
		html = frappe.get_template("templates/includes/full_index.html").render({
				"full_index": get_full_index(context.pathname, extn = extn),
				"url_prefix": context.url_prefix
			})

		out["content"] = out["content"].replace("{index}", html)

	# next and previous
	if "{next}" in out.get("content", ""):
		next_item = context.doc.get_next()
		next_item.extn = "" if context.doc.has_children(next_item.name) else extn
		if context.relative_links:
			next_item.name = next_item.page_name or ""
		else:
			if next_item and next_item.name and next_item.name[0]!="/":
				next_item.name = "/" + next_item.name

		if next_item and next_item.name:
			if not next_item.title:
				next_item.title = ""
			html = ('<p class="btn-next-wrapper"><a class="btn-next" href="{name}{extn}">'\
				+_("Next")+': {title}</a></p>').format(**next_item)
		else:
			html = ""

		out["content"] = out["content"].replace("{next}", html)
コード例 #4
0
ファイル: utils.py プロジェクト: JiShangShiDai/frappe
def get_toc(route, url_prefix=None, app=None):
	'''Insert full index (table of contents) for {index} tag'''
	from frappe.website.utils import get_full_index

	full_index = get_full_index(app=app)

	return frappe.get_template("templates/includes/full_index.html").render({
			"full_index": full_index,
			"url_prefix": url_prefix or "/",
			"route": route.rstrip('/')
		})
コード例 #5
0
ファイル: utils.py プロジェクト: hrwX/frappe
def get_toc(route, url_prefix=None, app=None):
	'''Insert full index (table of contents) for {index} tag'''
	from frappe.website.utils import get_full_index

	full_index = get_full_index(app=app)

	return frappe.get_template("templates/includes/full_index.html").render({
			"full_index": full_index,
			"url_prefix": url_prefix or "/",
			"route": route.rstrip('/')
		})
コード例 #6
0
ファイル: web_page.py プロジェクト: sagar30051991/frappe-oz
    def add_index(self, context):
        """Add index, next button if `{index}`, `{next}` is present."""
        # table of contents

        extn = ""
        if context.page_links_with_extn:
            extn = ".html"

        if "{index}" in context.main_section and context.get(
                "children") and len(context.children):
            full_index = get_full_index(context.pathname, extn=extn)

            if full_index:
                html = frappe.get_template(
                    "templates/includes/full_index.html").render({
                        "full_index":
                        full_index,
                        "url_prefix":
                        context.url_prefix
                    })

                context.main_section = context.main_section.replace(
                    "{index}", html)

        # next and previous
        if "{next}" in context.main_section:
            next_item = self.get_next()
            next_item.extn = "" if self.has_children(next_item.name) else extn
            if next_item and next_item.page_name:
                if context.relative_links:
                    if next_item.next_parent:
                        next_item.name = "../" + next_item.page_name or ""
                    else:
                        next_item.name = next_item.page_name or ""
                else:
                    if next_item and next_item.name and next_item.name[
                            0] != "/":
                        next_item.name = "/" + next_item.name

                if not next_item.title:
                    next_item.title = ""
                html = ('<p class="btn-next-wrapper">'+_("Next")\
                 +': <a class="btn-next" href="{name}{extn}">{title}</a></p>').format(**next_item)
            else:
                html = ""

            context.main_section = context.main_section.replace("{next}", html)
コード例 #7
0
ファイル: web_page.py プロジェクト: ansarbek/frappe
	def add_index(self, context):
		"""Add index, next button if `{index}`, `{next}` is present."""
		# table of contents

		extn = ""
		if context.page_links_with_extn:
			extn = ".html"

		if "{index}" in context.main_section and context.get("children") and len(context.children):
			full_index = get_full_index(context.pathname, extn = extn)

			if full_index:
				html = frappe.get_template("templates/includes/full_index.html").render({
					"full_index": full_index,
					"url_prefix": context.url_prefix
				})

				context.main_section = context.main_section.replace("{index}", html)

		# next and previous
		if "{next}" in context.main_section:
			next_item = self.get_next()
			next_item.extn = "" if self.has_children(next_item.name) else extn
			if next_item and next_item.page_name:
				if context.relative_links:
					if next_item.next_parent:
						next_item.name = "../" + next_item.page_name or ""
					else:
						next_item.name = next_item.page_name or ""
				else:
					if next_item and next_item.name and next_item.name[0]!="/":
						next_item.name = "/" + next_item.name

				if not next_item.title:
					next_item.title = ""
				html = ('<p class="btn-next-wrapper">'+_("Next")\
					+': <a class="btn-next" href="{name}{extn}">{title}</a></p>').format(**next_item)
			else:
				html = ""

			context.main_section = context.main_section.replace("{next}", html)
コード例 #8
0
ファイル: utils.py プロジェクト: GPD-ERP/frappe
def get_next_link(route, url_prefix=None, app=None):
    # insert next link
    next_item = None
    route = route.rstrip('/')
    children_map = get_full_index(app=app)
    parent_route = os.path.dirname(route)
    children = children_map.get(parent_route, None)

    if parent_route and children:
        for i, c in enumerate(children):
            if c.route == route and i < (len(children) - 1):
                next_item = children[i + 1]
                next_item.url_prefix = url_prefix or "/"

    if next_item:
        if next_item.route and next_item.title:
            html = ('<p class="btn-next-wrapper">' + frappe._("Next")\
             +': <a class="btn-next" href="{url_prefix}{route}">{title}</a></p>').format(**next_item)

            return html

    return ''
コード例 #9
0
ファイル: utils.py プロジェクト: JiShangShiDai/frappe
def get_next_link(route, url_prefix=None, app=None):
	# insert next link
	next_item = None
	route = route.rstrip('/')
	children_map = get_full_index(app=app)
	parent_route = os.path.dirname(route)
	children = children_map[parent_route]

	if parent_route and children:
		for i, c in enumerate(children):
			if c.route == route and i < (len(children) - 1):
				next_item = children[i+1]
				next_item.url_prefix = url_prefix or "/"

	if next_item:
		if next_item.route and next_item.title:
			html = ('<p class="btn-next-wrapper">' + frappe._("Next")\
				+': <a class="btn-next" href="{url_prefix}{route}">{title}</a></p>').format(**next_item)

			return html

	return ''
コード例 #10
0
def add_index(out, context):
    """Add index, next button if `{index}`, `{next}` is present."""
    # table of contents

    extn = ""
    if context.page_links_with_extn:
        extn = ".html"

    if "{index}" in out.get("content", "") and context.get("children"):
        html = frappe.get_template(
            "templates/includes/full_index.html").render({
                "full_index":
                get_full_index(context.pathname, extn=extn),
                "url_prefix":
                context.url_prefix
            })

        out["content"] = out["content"].replace("{index}", html)

    # next and previous
    if "{next}" in out.get("content", ""):
        next_item = context.doc.get_next()
        next_item.extn = "" if context.doc.has_children(
            next_item.name) else extn
        if context.relative_links:
            next_item.name = next_item.page_name or ""
        else:
            if next_item.name[0] != "/":
                next_item.name = "/" + next_item.name

        if next_item:
            if not next_item.title:
                next_item.title = ""
            html = ('<p class="btn-next-wrapper"><a class="btn-next" href="{name}{extn}">'\
             +_("Next")+': {title}</a></p>').format(**next_item)
        else:
            html = ""

        out["content"] = out["content"].replace("{next}", html)
コード例 #11
0
def get_context(context):
    context.full_index = get_full_index()
コード例 #12
0
ファイル: contents.py プロジェクト: Aptitudetech/ERPNext
def get_context(context):
	context.full_index = get_full_index()
コード例 #13
0
def get_context(context):
	for item in get_full_index():
		if item.page_name=="contents":
			context.full_index = item.children
			break
コード例 #14
0
def get_context(context):
    for item in get_full_index():
        if item.page_name == "contents":
            context.full_index = item.children
            break
コード例 #15
0
ファイル: contents.py プロジェクト: meeerp/jobtaskscheduler
def get_context(context):
    context.full_index = get_full_index(extn=True)