blob: dfaba02847d3fa214b1982a37b6ce5a19fb67ccd [file] [log] [blame]
Rushabh Mehta9db1a682013-04-02 10:41:37 +05301import webnotes, conf, os
Anand Doshi488a8212013-05-22 15:51:47 +05302from webnotes.utils import cint, cstr, encode
Rushabh Mehta9db1a682013-04-02 10:41:37 +05303
Rushabh Mehta9db1a682013-04-02 10:41:37 +05304def get_templates_path():
5 return os.path.join(os.path.dirname(conf.__file__), "app", "website", "templates")
6
Rushabh Mehta9db1a682013-04-02 10:41:37 +05307def get_home_page():
8 doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
9 if doc_name:
10 page_name = webnotes.conn.get_value('Web Page', doc_name, 'page_name')
11 else:
12 page_name = 'login'
13
14 return page_name
15
16def update_template_args(page_name, args):
17
18 from webnotes.utils import get_request_site_address
19 from urllib import quote
20
21 all_top_items = webnotes.conn.sql("""\
22 select * from `tabTop Bar Item`
23 where parent='Website Settings' and parentfield='top_bar_items'
24 order by idx asc""", as_dict=1)
25
26 top_items = [d for d in all_top_items if not d['parent_label']]
27
28 # attach child items to top bar
29 for d in all_top_items:
30 if d['parent_label']:
31 for t in top_items:
32 if t['label']==d['parent_label']:
33 if not 'child_items' in t:
34 t['child_items'] = []
35 t['child_items'].append(d)
36 break
Rushabh Mehtac382eb52013-06-11 12:03:37 +053037
Rushabh Mehta9db1a682013-04-02 10:41:37 +053038 ret = webnotes._dict({
39 'top_bar_items': top_items,
40 'footer_items': webnotes.conn.sql("""\
41 select * from `tabTop Bar Item`
42 where parent='Website Settings' and parentfield='footer_items'
43 order by idx asc""", as_dict=1),
44
45 'int':int,
46 "webnotes": webnotes,
47 "utils": webnotes.utils
48 })
49
50 args.update(ret)
51
52 settings = webnotes.doc("Website Settings", "Website Settings")
53 for k in ["banner_html", "brand_html", "copyright", "address", "twitter_share_via",
Anand Doshi07f69582013-05-02 15:51:45 +053054 "favicon", "facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
55 "disable_signup"]:
Rushabh Mehta9db1a682013-04-02 10:41:37 +053056 if k in settings.fields:
57 args[k] = settings.fields.get(k)
58
Anand Doshi07f69582013-05-02 15:51:45 +053059 for k in ["facebook_share", "google_plus_one", "twitter_share", "linked_in_share",
60 "disable_signup"]:
61 args[k] = cint(args.get(k) or 0)
Rushabh Mehta9db1a682013-04-02 10:41:37 +053062
Anand Doshicd772da2013-05-02 17:47:17 +053063 args.url = quote(str(get_request_site_address(full_address=True)), str(""))
Anand Doshi488a8212013-05-22 15:51:47 +053064 args.encoded_title = quote(encode(args.title or ""), str(""))
Rushabh Mehta9db1a682013-04-02 10:41:37 +053065
66 return args
67