From 5ab81631400bf6b8f473c65681291ad07d127e12 Mon Sep 17 00:00:00 2001 From: Rushabh Mehta Date: Tue, 8 May 2012 12:58:32 +0530 Subject: [PATCH] fixes to routing and activating web page --- .gitignore | 1 + .../website_settings/website_settings.py | 12 +- erpnext/website/utils.py | 2 +- public/js/all-app.js | 23 +- public/js/all-web.js | 15 +- public/js/wn-web.js | 4 +- public/login-page.html | 250 ++++++++++++++++++ 7 files changed, 284 insertions(+), 23 deletions(-) create mode 100644 public/login-page.html diff --git a/.gitignore b/.gitignore index 0e207280a7f..0547ba7bdfe 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,7 @@ version.num public/*.html !public/blank.html !public/unsupported.html +!public/login-page.html public/js/lib public/images/lib public/files diff --git a/erpnext/website/doctype/website_settings/website_settings.py b/erpnext/website/doctype/website_settings/website_settings.py index 53bf6c862fe..8bc7b29fea3 100644 --- a/erpnext/website/doctype/website_settings/website_settings.py +++ b/erpnext/website/doctype/website_settings/website_settings.py @@ -25,13 +25,21 @@ class DocType: * clear cache """ self.set_home_page() - self.validate_domain_list() + self.rewrite_pages() from webnotes.session_cache import clear_cache clear_cache('Guest') - + def rewrite_pages(self): + """rewrite all web pages""" + import webnotes + from webnotes.model.code import get_obj + + for p in webnotes.conn.sql("""select name from tabPage where docstatus=0 + and web_page = 'Yes'"""): + get_obj('Page', p[0]).write_cms_page() + def set_home_page(self): import webnotes diff --git a/erpnext/website/utils.py b/erpnext/website/utils.py index 04127bc0df9..7ec1b4f07c8 100644 --- a/erpnext/website/utils.py +++ b/erpnext/website/utils.py @@ -116,7 +116,7 @@ def get_header(): diff --git a/public/js/all-app.js b/public/js/all-app.js index 7f7e52c3567..b9b7933fe19 100644 --- a/public/js/all-app.js +++ b/public/js/all-app.js @@ -179,7 +179,8 @@ return repl('
%(letter)s
',args);}} -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));} +wn.get_cookie=function(c){var clist=(document.cookie+'').split(';');var cookies={};for(var i=0;i').html(label).attr('value',value).appendTo(this);} @@ -252,7 +253,8 @@ wn.re_route={} wn.route=function(){if(wn.re_route[window.location.hash]){window.location.hash=wn.re_route[window.location.hash];} wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');} wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}} -wn.get_route=function(route){return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});} +wn.get_route=function(route){if(!wn.boot){return[window.page_name];} +return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});} wn.get_route_str=function(route){if(!route) route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return route;} wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();} @@ -370,9 +372,9 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('\

Not Found


\ @@ -403,7 +405,7 @@ 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());}); +$(document).ready(function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js @@ -2110,11 +2112,7 @@ this.prepare_col_heads(this.flist);var table=me.make_print_table(this.flist);thi _e.email_as_field='email_id';_e.email_as_dt='Contact';_e.email_as_in='email_id,contact_name';sendmail=function(emailto,emailfrom,cc,subject,message,fmt,with_attachments){var fn=function(html){$c('webnotes.utils.email_lib.send_form',{'sendto':emailto,'sendfrom':emailfrom?emailfrom:'','cc':cc?cc:'','subject':subject,'message':replace_newlines(message),'body':html,'full_domain':wn.urllib.get_base_url(),'with_attachments':with_attachments?1:0,'dt':cur_frm.doctype,'dn':cur_frm.docname},function(r,rtxt){});} _p.build(fmt,fn);} _e.make=function(){var d=new Dialog(440,440,"Send Email");var email_go=function(){var emailfrom=d.widgets['From'].value;var emailto=d.widgets['To'].value;if(!emailfrom) -emailfrom=user_email;emailto=emailto.replace(/ /g,"") -var email_list=emailto.split(/[,|;]/);var valid=1;console.log(email_list) -for(var i=0;i').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});}); +wn.modules_path='erpnext';$(document).bind('toolbar_setup',function(){$('.brand').html((wn.boot.website_settings.brand_html||'erpnext')+' ').css('max-width','200px').css('overflow','hidden').hover(function(){$(this).find('.icon-home').addClass('navbar-icon-home-hover');},function(){$(this).find('.icon-home').removeClass('navbar-icon-home-hover');});}); \ No newline at end of file diff --git a/public/js/all-web.js b/public/js/all-web.js index 41bcb7380ab..d6a1120bd2f 100644 --- a/public/js/all-web.js +++ b/public/js/all-web.js @@ -66,7 +66,8 @@ return repl('
%(letter)s
',args);}} -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));} +wn.get_cookie=function(c){var clist=(document.cookie+'').split(';');var cookies={};for(var i=0;i').html(label).attr('value',value).appendTo(this);} @@ -139,7 +140,8 @@ wn.re_route={} wn.route=function(){if(wn.re_route[window.location.hash]){window.location.hash=wn.re_route[window.location.hash];} wn._cur_route=window.location.hash;route=wn.get_route();switch(route[0]){case"List":wn.views.doclistview.show(route[1]);break;case"Form":if(route.length>3){route[2]=route.splice(2).join('/');} wn.views.formview.show(route[1],route[2]);break;case"Report":wn.views.reportview.show(route[1],route[2]);break;case"Report2":wn.views.reportview2.show();break;default:wn.views.pageview.show(route[0]);}} -wn.get_route=function(route){return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});} +wn.get_route=function(route){if(!wn.boot){return[window.page_name];} +return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});} wn.get_route_str=function(route){if(!route) route=window.location.hash;if(route.substr(0,1)=='#')route=route.substr(1);if(route.substr(0,1)=='!')route=route.substr(1);return route;} wn.set_route=function(){route=$.map(arguments,function(a){return encodeURIComponent(a)}).join('/');window.location.hash=route;wn.app.set_favicon();} @@ -257,9 +259,9 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('\

Not Found


\ @@ -290,7 +292,7 @@ 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());}); +$(document).ready(function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());}); /* * lib/js/legacy/globals.js @@ -693,7 +695,8 @@ if(errfld.length)msgprint('Mandatory fields required in '+ */ wn.Application=Class.extend({init:function(){var me=this;if(window.app){wn.call({method:'startup',callback:function(r,rt){wn.provide('wn.boot');wn.boot=r;if(wn.boot.profile.name=='Guest'){window.location='index.html';return;} me.startup();}})}else{document.cookie="sid=Guest;expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/" -this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');wn.route();},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages) +this.startup();}},startup:function(){this.load_bootinfo();this.make_page_container();this.make_nav_bar();this.set_favicon();$(document).trigger('startup');if(wn.boot){wn.route();} +$(document).trigger('app_ready');},load_bootinfo:function(){if(wn.boot){LocalDB.sync(wn.boot.docs);wn.control_panel=wn.boot.control_panel;if(wn.boot.error_messages) console.log(wn.boot.error_messages) if(wn.boot.server_messages) msgprint(wn.boot.server_messages);this.set_globals();}else{this.set_as_guest();}},set_globals:function(){profile=wn.boot.profile;user=wn.boot.profile.name;user_fullname=wn.user_info(user).fullname;user_defaults=profile.defaults;user_roles=profile.roles;user_email=profile.email;sys_defaults=wn.boot.sysdefaults;},set_as_guest:function(){profile={name:'Guest'};user='Guest';user_fullname='Guest';user_defaults={};user_roles=['Guest'];user_email='';sys_defaults={};},make_page_container:function(){wn.container=new wn.views.Container();wn.views.make_403();wn.views.make_404();},make_nav_bar:function(){if(wn.boot){wn.container.wntoolbar=new wn.ui.toolbar.Toolbar();}},logout:function(){var me=this;me.logged_out=true;wn.call({method:'logout',callback:function(r){if(r.exc){console.log(r.exc);} diff --git a/public/js/wn-web.js b/public/js/wn-web.js index c906fb7439a..52695636595 100644 --- a/public/js/wn-web.js +++ b/public/js/wn-web.js @@ -1,5 +1,5 @@ -window._version_number = "d9f42d1e15307de62f68d890d4e40adbe2472a85153ddc965775bebd"; -window.home_page = "Login Page"; +window._version_number = "c1dee2b8be9abfbe2a74619482b586b538f7253911fcb06c4c950b10"; +window.home_page = "index"; // footer signup widget // automatically adds it to the .layout-main div of the page // adds events and also random goodies. diff --git a/public/login-page.html b/public/login-page.html new file mode 100644 index 00000000000..5b70f86bfde --- /dev/null +++ b/public/login-page.html @@ -0,0 +1,250 @@ + + + + Login Page + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Login Id
Password
Remember Me
  
  + +
+

Forgot Password

+
+
+
+
+ + \ No newline at end of file