コード例 #1
0
ファイル: profile.py プロジェクト: rohitw1991/wnframework
    def send_login_mail(self, subject, txt, password):
        """send mail with login details"""
        import os

        import startup
        from webnotes.utils.email_lib import sendmail_md
        from webnotes.profile import get_user_fullname
        from webnotes.utils import get_request_site_address

        args = {
            'first_name': self.doc.first_name or self.doc.last_name or "user",
            'user': self.doc.name,
            'password': password,
            'company': webnotes.conn.get_default('company')
            or startup.product_name,
            'login_url': get_request_site_address(),
            'product': startup.product_name,
            'user_fullname': get_user_fullname(webnotes.session['user'])
        }

        sender = webnotes.session.user not in (
            "Administrator", "Guest") and webnotes.session.user or None

        sendmail_md(recipients=self.doc.email,
                    sender=sender,
                    subject=subject,
                    msg=txt % args)
コード例 #2
0
ファイル: bulk.py プロジェクト: mehulsbhatt/wnframework
	def add_unsubscribe_link(email):
		from webnotes.utils import get_request_site_address
		return message + """<div style="padding: 7px; border-top: 1px solid #aaa;
			margin-top: 17px;">
			<small><a href="http://%s/server.py?cmd=%s&email=%s&type=%s&email_field=%s">
			Unsubscribe</a> from this list.</small></div>""" % (get_request_site_address(), 
			'webnotes.utils.email_lib.bulk.unsubscribe', email, doctype, email_field)
コード例 #3
0
def get_context():
	"""generate rss feed"""
		
	host = get_request_site_address()
	
	blog_list = webnotes.conn.sql("""\
		select page_name as name, published_on, modified, title, content from `tabBlog Post` 
		where ifnull(published,0)=1
		order by published_on desc limit 20""", as_dict=1)

	for blog in blog_list:
		blog.link = urllib.quote(host + '/' + blog.name + '.html')
		blog.content = escape_html(blog.content or "")
	
	if blog_list:
		modified = max((blog['modified'] for blog in blog_list))
	else:
		modified = now()

	ws = webnotes.doc('Website Settings', 'Website Settings')

	context = {
		'title': ws.title_prefix,
		'description': ws.description or ((ws.title_prefix or "") + ' Blog'),
		'modified': modified,
		'items': blog_list,
		'link': host + '/blog'
	}
	
	webnotes.response.content_type = "text/xml"
	
	# print context
	return context
	
コード例 #4
0
ファイル: utils.py プロジェクト: PhamThoTam/erpnext
def get_outer_env(page_name, args):
	from webnotes.utils import get_request_site_address
	from urllib import quote
	
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
	
	if top_items and ("products" in [d.url.split(".")[0] for d in top_items if d.url]):
		# product categories
		products = webnotes.conn.sql("""select t1.item_group as label, 
			t2.page_name as url,
			ifnull(t1.indent,0) as indent
			from `tabWebsite Product Category` t1, `tabItem Group` t2 
			where t1.item_group = t2.name
			and ifnull(t2.show_in_website,0)=1 order by t1.idx""", as_dict=1)
		products_item = filter(lambda d: d.url and d.url.split(".")[0]=="products", top_items)[0]			
		products_item.child_items = products
		
	ret = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
			
		'int':int,
		"webnotes": webnotes,
		"utils": webnotes.utils
	})
	
	args.update(ret)
	
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "address", "twitter_share_via"
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share"]:
		if k in settings.fields:
			args[k] = settings.fields.get(k)

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share"]:
		args[k] = int(args.get(k) or 0)
	
	args.url = quote(str(get_request_site_address(full_address=True)), str(""))
	args.encoded_title = quote(str(args.title or ""), str(""))
	
	return args
コード例 #5
0
def get_website_settings():
	from webnotes.utils import get_request_site_address, encode, cint
	from urllib import quote
		
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
					
	context = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"webnotes": webnotes,
		"utils": webnotes.utils,
		"post_login": [
			{"label": "Reset Password", "url": "update-password", "icon": "icon-key"},
			{"label": "Logout", "url": "/?cmd=web_logout", "icon": "icon-signout"}
		]
	})
		
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			context[k] = settings.fields.get(k)
			
	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = cint(context.get(k) or 0)
	
	context.url = quote(str(get_request_site_address(full_address=True)), str(""))
	context.encoded_title = quote(encode(context.title or ""), str(""))
	
	try:
		import startup.webutils
		if hasattr(startup.webutils, "get_website_settings"):
			startup.webutils.get_website_settings(context)
	except:
		pass
	return context
コード例 #6
0
ファイル: webutils.py プロジェクト: ricardomomm/wnframework
def get_website_settings():
	from webnotes.utils import get_request_site_address, encode, cint
	from urllib import quote
		
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
					
	context = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"webnotes": webnotes,
		"utils": webnotes.utils,
		"post_login": [
			{"label": "Reset Password", "url": "update-password", "icon": "icon-key"},
			{"label": "Logout", "url": "/?cmd=web_logout", "icon": "icon-signout"}
		]
	})
		
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			context[k] = settings.fields.get(k)
			
	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = cint(context.get(k) or 0)
	
	context.url = quote(str(get_request_site_address(full_address=True)), str(""))
	context.encoded_title = quote(encode(context.title or ""), str(""))
	
	try:
		import startup.webutils
		if hasattr(startup.webutils, "get_website_settings"):
			startup.webutils.get_website_settings(context)
	except:
		pass
	return context
コード例 #7
0
ファイル: backup_dropbox.py プロジェクト: Jdfkat/erpnext
def get_dropbox_authorize_url():
    sess = get_dropbox_session()
    request_token = sess.obtain_request_token()
    return_address = (
        get_request_site_address(True) + "?cmd=setup.doctype.backup_manager.backup_dropbox.dropbox_callback"
    )

    url = sess.build_authorize_url(request_token, return_address)

    return {"url": url, "key": request_token.key, "secret": request_token.secret}
コード例 #8
0
def get_url():
	from webnotes.utils import get_request_site_address
	url = get_request_site_address()
	if not url or "localhost" in url:
		subdomain = webnotes.conn.get_value("Website Settings", "Website Settings",
			"subdomain")
		if subdomain:
			if "http" not in subdomain:
				url = "http://" + subdomain
	return url
コード例 #9
0
def get_site_address():
    from webnotes.utils import get_request_site_address
    url = get_request_site_address()

    if not url or url == 'http://localhost':
        new_url = webnotes.conn.get_value('Website Settings',
                                          'Website Settings', 'subdomain')
        if new_url:
            url = "http://" + new_url

    return url
コード例 #10
0
ファイル: assign_to.py プロジェクト: IPenuelas/wnframework
def notify_assignment(assigned_by, owner, doc_type, doc_name, action='CLOSE', notify=0):
	"""
		Notify assignee that there is a change in assignment
	"""	
	if not (assigned_by and owner and doc_type and doc_name): return

	# self assignment / closing - no message
	if assigned_by==owner:
		return

	from webnotes.boot import get_fullnames
	user_info = get_fullnames()

	# Search for email address in description -- i.e. assignee
	try:
		from startup import get_url
		url = get_url()
	except ImportError:
		from webnotes.utils import get_request_site_address
		url = get_request_site_address()

	assignment = """<a href="%s/app.html#!Form/%s/%s">%s: %s</a>""" % (url, 
		doc_type, doc_name,	doc_type, doc_name)
		
	if action=='CLOSE':
		if owner == webnotes.session.get('user'):
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, has been \
					closed." % (assignment,
						user_info.get(owner, {}).get('fullname'))
			}
		else:
			arg = {
				'contact': assigned_by,
				'txt': "The task %s, that you assigned to %s, \
					has been closed	by %s." % (assignment,
					user_info.get(owner, {}).get('fullname'),
					user_info.get(webnotes.session.get('user'),
						{}).get('fullname'))
			}
	else:
		arg = {
			'contact': owner,
			'txt': "A new task, %s, has been assigned to you by %s." \
				% (assignment,
				user_info.get(webnotes.session.get('user'), {}).get('fullname')),
			'notify': notify
		}
		
	arg["parenttype"] = "Assignment"
	from utilities.page.messages import messages
	import json
	messages.post(json.dumps(arg))
コード例 #11
0
ファイル: __init__.py プロジェクト: MrTomato8/erpnext
def get_site_address():
	from webnotes.utils import get_request_site_address
	url = get_request_site_address()

	if not url or url=='http://localhost':
		new_url = webnotes.conn.get_value('Website Settings', 'Website Settings',
			'subdomain')
		if new_url:
			url = "http://" + new_url
			
	return url
コード例 #12
0
ファイル: webutils.py プロジェクト: BANSALJEE/erpnext
def update_template_args(page_name, args):
	
	from webnotes.utils import get_request_site_address
	from urllib import quote
	
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
			
	ret = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
			
		'int':int,
		"webnotes": webnotes,
		"utils": webnotes.utils
	})
	
	args.update(ret)
	
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "address", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			args[k] = settings.fields.get(k)

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		args[k] = cint(args.get(k) or 0)
	
	args.url = quote(str(get_request_site_address(full_address=True)), str(""))
	args.encoded_title = quote(encode(args.title or ""), str(""))
	args.shopping_cart_enabled = cint(webnotes.conn.get_default("shopping_cart_enabled"))
	
	return args
コード例 #13
0
ファイル: bulk.py プロジェクト: MiteshC/wnframework
	def add_unsubscribe_link(email):
		from webnotes.utils import get_request_site_address
		import urllib
		return message + """<div style="padding: 7px; border-top: 1px solid #aaa;
			margin-top: 17px;">
			<small><a href="%s/server.py?%s">
			Unsubscribe</a> from this list.</small></div>""" % (get_request_site_address(), 
			urllib.urlencode({
				"cmd": "webnotes.utils.email_lib.bulk.unsubscribe",
				"email": email,
				"type": doctype,
				"email_field": email_field
			}))
コード例 #14
0
def get_dropbox_authorize_url():
    sess = get_dropbox_session()
    request_token = sess.obtain_request_token()
    return_address = get_request_site_address(True) \
     + "?cmd=setup.doctype.backup_manager.backup_dropbox.dropbox_callback"

    url = sess.build_authorize_url(request_token, return_address)

    return {
        "url": url,
        "key": request_token.key,
        "secret": request_token.secret,
    }
コード例 #15
0
	def add_unsubscribe_link(email):
		from webnotes.utils import get_request_site_address
		import urllib
		return message + """<div style="padding: 7px; border-top: 1px solid #aaa;
			margin-top: 17px;">
			<small><a href="%s/server.py?%s">
			Unsubscribe</a> from this list.</small></div>""" % (get_request_site_address(), 
			urllib.urlencode({
				"cmd": "webnotes.utils.email_lib.bulk.unsubscribe",
				"email": email,
				"type": doctype,
				"email_field": email_field
			}))
コード例 #16
0
ファイル: sitemap.py プロジェクト: ricardomomm/wnframework
def get_context():
	"""generate the sitemap XML"""
	links = webnotes.webutils.get_website_sitemap().items()
	host = get_request_site_address()
	
	for l in links:
		l[1]["loc"] = urllib.basejoin(host, urllib.quote(l[1].get("page_name", l[1]["link_name"]).encode("utf-8")))
	
	webnotes.response.content_type = "text/xml"
	
	return {
		"links": [l[1] for l in links if not l[1].get("no_sitemap")]
	}
	
コード例 #17
0
ファイル: sitemap.py プロジェクト: ricardomomm/wnframework
def get_context():
    """generate the sitemap XML"""
    links = webnotes.webutils.get_website_sitemap().items()
    host = get_request_site_address()

    for l in links:
        l[1]["loc"] = urllib.basejoin(
            host,
            urllib.quote(l[1].get("page_name",
                                  l[1]["link_name"]).encode("utf-8")))

    webnotes.response.content_type = "text/xml"

    return {"links": [l[1] for l in links if not l[1].get("no_sitemap")]}
コード例 #18
0
ファイル: sitemap.py プロジェクト: bindscha/wnframework_old
def get_context(context):
	"""generate the sitemap XML"""
	host = get_request_site_address()
	links = []
	for l in webnotes.conn.sql("""select `tabWebsite Sitemap`.page_name, `tabWebsite Sitemap`.lastmod 
		from `tabWebsite Sitemap`, `tabWebsite Sitemap Config` 
		where 
			`tabWebsite Sitemap`.website_sitemap_config = `tabWebsite Sitemap Config`.name
			and ifnull(`tabWebsite Sitemap Config`.no_sitemap, 0)=0""", 
		as_dict=True):
		links.append({
			"loc": urllib.basejoin(host, urllib.quote(l.page_name.encode("utf-8"))),
			"lastmod": l.lastmod
		})
	
	return {"links":links}
	
コード例 #19
0
def get_context():
    """generate the sitemap XML"""
    host = get_request_site_address()
    links = []
    for l in webnotes.conn.sql(
            """select `tabWebsite Sitemap`.page_name, `tabWebsite Sitemap`.lastmod 
		from `tabWebsite Sitemap`, `tabWebsite Sitemap Config` 
		where 
			`tabWebsite Sitemap`.website_sitemap_config = `tabWebsite Sitemap Config`.name
			and ifnull(`tabWebsite Sitemap Config`.no_sitemap, 0)=0""",
            as_dict=True):
        links.append({
            "loc":
            urllib.basejoin(host, urllib.quote(l.page_name.encode("utf-8"))),
            "lastmod":
            l.lastmod
        })

    return {"links": links}
コード例 #20
0
ファイル: profile.py プロジェクト: IPenuelas/wnframework
	def send_login_mail(self, subject, txt, password):
		"""send mail with login details"""
		import os
	
		import startup
		from webnotes.utils.email_lib import sendmail_md
		from webnotes.profile import get_user_fullname
		from webnotes.utils import get_request_site_address
	
		args = {
			'first_name': self.doc.first_name or self.doc.last_name or "user",
			'user': self.doc.name,
			'password': password,
			'company': webnotes.conn.get_default('company') or startup.product_name,
			'login_url': get_request_site_address(),
			'product': startup.product_name,
			'user_fullname': get_user_fullname(webnotes.session['user'])
		}
		sendmail_md(self.doc.email, subject=subject, msg=txt % args)
コード例 #21
0
ファイル: profile.py プロジェクト: kassemshehady/wnframework
    def send_login_mail(self, subject, txt, password):
        """send mail with login details"""
        import os

        import startup
        from webnotes.utils.email_lib import sendmail_md
        from webnotes.profile import get_user_fullname
        from webnotes.utils import get_request_site_address

        args = {
            "first_name": self.doc.first_name or self.doc.last_name or "user",
            "user": self.doc.name,
            "password": password,
            "company": webnotes.conn.get_default("company") or startup.product_name,
            "login_url": get_request_site_address(),
            "product": startup.product_name,
            "user_fullname": get_user_fullname(webnotes.session["user"]),
        }

        sender = webnotes.session.user not in ("Administrator", "Guest") and webnotes.session.user or None

        sendmail_md(recipients=self.doc.email, sender=sender, subject=subject, msg=txt % args)
コード例 #22
0
ファイル: webutils.py プロジェクト: rohitw1991/latestadberp
def update_template_args(page_name, args):

    from webnotes.utils import get_request_site_address
    from urllib import quote

    all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""",
                                      as_dict=1)

    top_items = [d for d in all_top_items if not d['parent_label']]

    # attach child items to top bar
    for d in all_top_items:
        if d['parent_label']:
            for t in top_items:
                if t['label'] == d['parent_label']:
                    if not 'child_items' in t:
                        t['child_items'] = []
                    t['child_items'].append(d)
                    break

    ret = webnotes._dict({
        'top_bar_items':
        top_items,
        'footer_items':
        webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""",
                          as_dict=1),
        'int':
        int,
        "webnotes":
        webnotes,
        "utils":
        webnotes.utils
    })

    args.update(ret)

    settings = webnotes.doc("Website Settings", "Website Settings")
    for k in [
            "banner_html", "brand_html", "copyright", "address",
            "twitter_share_via", "favicon", "facebook_share",
            "google_plus_one", "twitter_share", "linked_in_share",
            "disable_signup"
    ]:
        if k in settings.fields:
            args[k] = settings.fields.get(k)

    for k in [
            "facebook_share", "google_plus_one", "twitter_share",
            "linked_in_share", "disable_signup"
    ]:
        args[k] = cint(args.get(k) or 0)

    args.url = quote(str(get_request_site_address(full_address=True)), str(""))
    args.encoded_title = quote(encode(args.title or ""), str(""))
    args.shopping_cart_enabled = cint(
        webnotes.conn.get_default("shopping_cart_enabled"))

    return args
コード例 #23
0
ファイル: webutils.py プロジェクト: bindscha/wnframework_old
def get_website_settings():
	# TODO Cache this
	hooks = webnotes.get_hooks()
	
	all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""", as_dict=1)
	
	top_items = [d for d in all_top_items if not d['parent_label']]
	
	# attach child items to top bar
	for d in all_top_items:
		if d['parent_label']:
			for t in top_items:
				if t['label']==d['parent_label']:
					if not 'child_items' in t:
						t['child_items'] = []
					t['child_items'].append(d)
					break
					
	context = webnotes._dict({
		'top_bar_items': top_items,
		'footer_items': webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""", as_dict=1),
		"post_login": [
			{"label": "Reset Password", "url": "update-password", "icon": "icon-key"},
			{"label": "Logout", "url": "?cmd=web_logout", "icon": "icon-signout"}
		]
	})
		
	settings = webnotes.doc("Website Settings", "Website Settings")
	for k in ["banner_html", "brand_html", "copyright", "twitter_share_via",
		"favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		if k in settings.fields:
			context[k] = settings.fields.get(k)
			
	if settings.address:
		context["footer_address"] = settings.address

	for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
		"disable_signup"]:
		context[k] = cint(context.get(k) or 0)
	
	context.url = quote(str(get_request_site_address(full_address=True)), safe="/:")
	context.encoded_title = quote(encode(context.title or ""), str(""))
	
	for update_website_context in hooks.update_website_context or []:
		webnotes.get_attr(update_website_context)(context)
		
	context.web_include_js = hooks.web_include_js or []
	context.web_include_css = hooks.web_include_css or []
	
	# get settings from site config
	if webnotes.conf.get("fb_app_id"):
		context.fb_app_id = webnotes.conf.fb_app_id
	
	return context
コード例 #24
0
ファイル: website.py プロジェクト: rohitw1991/erpnext
def update_template_args(page_name, args):

    from webnotes.utils import get_request_site_address
    from urllib import quote

    all_top_items = webnotes.conn.sql("""\
		select * from `tabTop Bar Item`
		where parent='Website Settings' and parentfield='top_bar_items'
		order by idx asc""",
                                      as_dict=1)

    top_items = [d for d in all_top_items if not d['parent_label']]

    # attach child items to top bar
    for d in all_top_items:
        if d['parent_label']:
            for t in top_items:
                if t['label'] == d['parent_label']:
                    if not 'child_items' in t:
                        t['child_items'] = []
                    t['child_items'].append(d)
                    break

    if top_items and ("products"
                      in [d.url.split(".")[0] for d in top_items if d.url]):
        # product categories
        products = webnotes.conn.sql("""select t1.item_group as label, 
			t2.page_name as url,
			ifnull(t1.indent,0) as indent
			from `tabWebsite Product Category` t1, `tabItem Group` t2 
			where t1.item_group = t2.name
			and ifnull(t2.show_in_website,0)=1 order by t1.idx""",
                                     as_dict=1)
        products_item = filter(
            lambda d: d.url and d.url.split(".")[0] == "products",
            top_items)[0]
        products_item.child_items = products

    ret = webnotes._dict({
        'top_bar_items':
        top_items,
        'footer_items':
        webnotes.conn.sql("""\
			select * from `tabTop Bar Item`
			where parent='Website Settings' and parentfield='footer_items'
			order by idx asc""",
                          as_dict=1),
        'int':
        int,
        "webnotes":
        webnotes,
        "utils":
        webnotes.utils
    })

    args.update(ret)

    settings = webnotes.doc("Website Settings", "Website Settings")
    for k in [
            "banner_html", "brand_html", "copyright", "address",
            "twitter_share_via", "favicon", "facebook_share",
            "google_plus_one", "twitter_share", "linked_in_share",
            "disable_signup"
    ]:
        if k in settings.fields:
            args[k] = settings.fields.get(k)

    for k in [
            "facebook_share", "google_plus_one", "twitter_share",
            "linked_in_share", "disable_signup"
    ]:
        args[k] = cint(args.get(k) or 0)

    args.url = quote(str(get_request_site_address(full_address=True)), str(""))
    args.encoded_title = quote(encode(args.title or ""), str(""))

    return args