\
@@ -281,4 +283,4 @@ wn.request.call({args:args,success:opts.callback,error:opts.error,btn:opts.btn,f
* lib/js/core.js
*/
if(!console){var console={log:function(txt){}}}
-$(document).bind('ready',function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
\ No newline at end of file
+$(document).ready(function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
\ No newline at end of file
diff --git a/js/wn/app.js b/js/wn/app.js
index 92bef1c6c9..700766c40c 100644
--- a/js/wn/app.js
+++ b/js/wn/app.js
@@ -55,11 +55,16 @@ wn.Application = Class.extend({
// favicon
this.set_favicon();
+
// trigger app startup
$(document).trigger('startup');
- // route to home page
- wn.route();
+ if(wn.boot) {
+ // route to home page
+ wn.route();
+ }
+
+ $(document).trigger('app_ready');
},
load_bootinfo: function() {
if(wn.boot) {
diff --git a/js/wn/dom.js b/js/wn/dom.js
index 58c36f03ce..cd38300500 100644
--- a/js/wn/dom.js
+++ b/js/wn/dom.js
@@ -111,12 +111,13 @@ wn.dom = {
}
wn.get_cookie = function(c) {
- var t=""+document.cookie;
- var ind=t.indexOf(c);
- if (ind==-1 || c=="") return "";
- var ind1=t.indexOf(';',ind);
- if (ind1==-1) ind1=t.length;
- return unescape(t.substring(ind+c.length+1,ind1));
+ var clist = (document.cookie+'').split(';');
+ var cookies = {};
+ for(var i=0;iLogin Page
-
-
Powered by Web Notes Framework
\ No newline at end of file
diff --git a/py/webnotes/__init__.py b/py/webnotes/__init__.py
index 1e35ab6870..c97af4a990 100644
--- a/py/webnotes/__init__.py
+++ b/py/webnotes/__init__.py
@@ -213,12 +213,13 @@ def clear_cache(user=None):
from webnotes.session_cache import clear
clear(user)
-def get_roles():
+def get_roles(user=None):
"""get roles of current user"""
- if session['user']=='Guest':
+ if not user:
+ user = session['user']
+
+ if user=='Guest':
return ['Guest']
- roles = [r[0] for r in conn.sql("""select distinct role from tabUserRole
- where parent=%s and role!='All'""", session['user'])]
-
- return roles + ['All']
+ return [r[0] for r in conn.sql("""select distinct role from tabUserRole
+ where parent=%s and role!='All'""", user)] + ['All']
diff --git a/py/webnotes/boot.py b/py/webnotes/boot.py
index 35ab8498eb..b8b2515f31 100644
--- a/py/webnotes/boot.py
+++ b/py/webnotes/boot.py
@@ -52,7 +52,7 @@ def get_bootinfo():
bootinfo['sid'] = webnotes.session['sid'];
# home page
- get_home_page(bootinfo, doclist)
+ add_home_page(bootinfo, doclist)
# ipinfo
if webnotes.session['data'].get('ipinfo'):
@@ -99,12 +99,13 @@ def get_profile(bootinfo):
bootinfo['profile'] = webnotes.user.load_profile()
webnotes.session['data']['profile'] = bootinfo['profile']
-def get_home_page(bootinfo, doclist):
+def add_home_page(bootinfo, doclist):
"""load home page"""
import webnotes
import webnotes.widgets.page
+ import webnotes.cms
- home_page = webnotes.user.get_home_page() or 'Login Page'
+ home_page = webnotes.cms.get_home_page(webnotes.session['user']) or 'Login Page'
try:
page_doclist = webnotes.widgets.page.get(home_page)
diff --git a/py/webnotes/cms/__init__.py b/py/webnotes/cms/__init__.py
index eb3037d139..42a9706412 100644
--- a/py/webnotes/cms/__init__.py
+++ b/py/webnotes/cms/__init__.py
@@ -1,48 +1,3 @@
-"""
-make index, wn.js, wn.css pages
-- rebuild all pages on change of website settings (toolbar)
-- if home, write index.html
-"""
-def make(version):
- import os
- import webnotes
- from webnotes.model.code import get_obj
- from jinja2 import Template
-
- webnotes.connect()
-
- # get web home
- home_page = webnotes.conn.get_default("web_home_page") or 'Login Page'
-
- page = get_obj('Page', home_page)
- page.get_from_files()
-
- os.chdir('public')
-
- page.write_cms_page(home_page=True)
-
- # script - wn.js
- import startup.event_handlers
- if hasattr(startup.event_handlers, 'get_web_script'):
- with open('js/wn-web.js', 'w') as f:
-
- script = 'window._version_number = "%s";\n' % version
- script += 'window.home_page = "%s";\n' % home_page
-
- script += startup.event_handlers.get_web_script()
-
- f.write(script)
-
- # style - wn.css
- if hasattr(startup.event_handlers, 'get_web_style'):
- with open('css/wn-web.css', 'w') as f:
- f.write(startup.event_handlers.get_web_style())
-
- # make app.html
- with open('../lib/conf/app.html', 'r') as app_template:
- with open('app.html', 'w') as app:
- app.write(Template(app_template.read()).render(version=version))
-
def page_name(title):
"""truncated page name"""
@@ -50,3 +5,18 @@ def page_name(title):
name = title.lower()
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
return '-'.join(name.split()[:4])
+
+def get_home_page(user=None):
+ """get home page for user"""
+ if not user:
+ user = 'Guest'
+ import webnotes
+ hpl = webnotes.conn.sql("""select home_page
+ from `tabDefault Home Page`
+ where parent='Control Panel'
+ and role in ('%s') order by idx asc limit 1""" % "', '".join(webnotes.get_roles(user)))
+
+ if hpl:
+ return hpl[0][0]
+ else:
+ return webnotes.conn.get_value('Control Panel',None,'home_page') or 'Login Page'
\ No newline at end of file
diff --git a/py/webnotes/cms/index.py b/py/webnotes/cms/index.py
deleted file mode 100644
index 7cfe1efd6c..0000000000
--- a/py/webnotes/cms/index.py
+++ /dev/null
@@ -1,120 +0,0 @@
-# Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
-#
-# MIT License (MIT)
-#
-# Permission is hereby granted, free of charge, to any person obtaining a
-# copy of this software and associated documentation files (the "Software"),
-# to deal in the Software without restriction, including without limitation
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,
-# and/or sell copies of the Software, and to permit persons to whom the
-# Software is furnished to do so, subject to the following conditions:
-#
-# The above copyright notice and this permission notice shall be included in
-# all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
-# INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
-# PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
-# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
-# OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-"""
-Generate index.cgi html
-
-Loads index.html from the template with:
-
-1. bootinfo
-2. static html of home / if _escaped_fragment_ is given
-3. top menus and bottom menus
-
-"""
-
-import webnotes
-
-body_html = """
-
-
-
-
-
-
- %s
-
-
-"""
-
-def get():
- """get index html"""
- import webnotes
- from jinja2 import Template
-
- with open('lib/conf/index.html', 'r') as f:
- template = Template(f.read())
-
- # google crawler
- if '_escaped_fragment_' in webnotes.form:
- page = webnotes.form_dict['_escaped_fragment_']
- if not page:
- page = webnotes.user.get_home_page()
-
- return template.render(bootinfo = '', style_tag='', version='0', analytics_code = '',
- script_tag = '', body_html=html_snapshot(page), ajax_meta_tag = '',
- title=webnotes.conn.get_value('Page', page, 'title'))
-
- # home page
- else:
- import webnotes.session_cache
- from build.project import get_version
- import json
-
- bootdict = webnotes.session_cache.get()
- bootinfo = """var wn = {}; wn.boot = %s;""" % json.dumps(bootdict)
-
- return template.render(bootinfo = bootinfo, version = get_version(),
- script_tag = script_tag, style_tag = style_tag, body_html=body_html % '')
-
-def html_snapshot(page):
- """get html snapshot for search bot"""
- from webnotes.widgets.page import get_page_html
- from webnotes.model.doc import Document
-
- doc = Document('Website Settings', 'Website Settings')
- doc.content = get_page_html(page)
- doc.header_menu = doc.footer_menu = ''
- doc.page_name = page
-
- for m in webnotes.conn.sql("""select parentfield, label, url, custom_page
- from `tabTop Bar Item` where parent='Top Bar Settings' order by idx""", as_dict=1):
-
- m['std_page'] = m.get('url') or m.get('custom_page')
-
- if m['parentfield']=='top_bar_items':
- doc.header_menu += '