cms updates
This commit is contained in:
parent
db12af6954
commit
098b7e288d
17 changed files with 148 additions and 231 deletions
|
|
@ -12,8 +12,19 @@
|
|||
<link type="text/css" rel="stylesheet" href="css/wn-web.css">
|
||||
{% if script %}
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
window.page_name = "{{ name }}";
|
||||
|
||||
$(document).bind('app_ready', function() {
|
||||
var _page = new wn.views.Page(window.page_name);
|
||||
|
||||
// page script
|
||||
{{ script }}
|
||||
|
||||
// trigger onload
|
||||
_page.trigger('onload');
|
||||
|
||||
// activate page
|
||||
wn.container.change_to(window.page_name);
|
||||
});
|
||||
</script>
|
||||
{% endif %}
|
||||
|
|
@ -32,7 +32,7 @@ if(!console) {
|
|||
|
||||
|
||||
/* start the application */
|
||||
$(document).bind('ready', function() {
|
||||
$(document).ready(function() {
|
||||
wn.versions.check();
|
||||
wn.provide('wn.app');
|
||||
$.extend(wn.app, new wn.Application());
|
||||
|
|
|
|||
12
js/core.min.js
vendored
12
js/core.min.js
vendored
|
|
@ -57,7 +57,8 @@ return repl('<div style="\
|
|||
background: linear-gradient(top, #%(col1)s 0%,#%(col2)s 99%); /* W3C */\
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr=\'#%(col1)s\', endColorstr=\'#%(col2)s\',GradientType=0 ); /* IE6-9 */\
|
||||
">%(letter)s</div>',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<clist.length;i++){var tmp=clist[i].split('=');cookies[strip(tmp[0])]=strip(tmp[1]);}
|
||||
return cookies[c];}
|
||||
wn.dom.set_box_shadow=function(ele,spread){$(ele).css('-moz-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-webkit-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')
|
||||
$(ele).css('-box-shadow','0px 0px '+spread+'px rgba(0,0,0,0.3);')};(function($){$.fn.add_options=function(options_list){for(var i=0;i<options_list.length;i++){var v=options_list[i];value=v.value||v;label=v.label||v;$('<option>').html(label).attr('value',value).appendTo(this);}
|
||||
|
|
@ -130,7 +131,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();}
|
||||
|
|
@ -248,9 +250,9 @@ wn.views.add_list_btn=function(parent,doctype){$(parent).append(repl('<span clas
|
|||
/*
|
||||
* lib/js/wn/views/pageview.js
|
||||
*/
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={pages:{},with_page:function(name,callback){if((locals.Page&&locals.Page[name])||name==window.home_page){callback();}else{wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}},show:function(name){if(!name)name=(wn.boot?wn.boot.home_page:'Login Page');wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){wn.views.pageview.pages[name]=new wn.views.Page(name);}
|
||||
wn.provide('wn.views.pageview');wn.views.pageview={with_page:function(name,callback){if((locals.Page&&locals.Page[name])||name==window.page_name){callback();}else{wn.call({method:'webnotes.widgets.page.getpage',args:{'name':name},callback:callback});}},show:function(name){if(!name)name=(wn.boot?wn.boot.home_page:window.page_name);wn.views.pageview.with_page(name,function(r){if(r&&r.exc){if(!r['403'])wn.container.change_to('404');}else if(!wn.pages[name]){new wn.views.Page(name);}
|
||||
wn.container.change_to(name);});}}
|
||||
wn.views.Page=Class.extend({init:function(name,wrapper){this.name=name;var me=this;if(name==window.home_page){this.wrapper=document.getElementById('page-'+name);this.wrapper.title=document.title;this.wrapper.label=window.home_page;}else{this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');}
|
||||
wn.views.Page=Class.extend({init:function(name,wrapper){this.name=name;var me=this;if(name==window.page_name){this.wrapper=document.getElementById('page-'+name);this.wrapper.title=document.title;this.wrapper.label=window.page_name;wn.pages[window.page_name]=this.wrapper;}else{this.pagedoc=locals.Page[this.name];this.wrapper=wn.container.add_page(this.name);this.wrapper.label=this.pagedoc.title||this.pagedoc.name;this.wrapper.page_name=this.pagedoc.name;this.wrapper.innerHTML=this.pagedoc.content;wn.dom.eval(this.pagedoc.__script||this.pagedoc.script||'');wn.dom.set_style(this.pagedoc.style||'');}
|
||||
this.trigger('onload');$(this.wrapper).bind('show',function(){cur_frm=null;me.trigger('onshow');me.trigger('refresh');});},trigger:function(eventname){var me=this;try{if(pscript[eventname+'_'+this.name]){pscript[eventname+'_'+this.name](me.wrapper);}else if(me.wrapper[eventname]){me.wrapper[eventname](me.wrapper);}}catch(e){console.log(e);}}})
|
||||
wn.views.make_404=function(){var page=wn.container.add_page('404');$(page).html('<div class="layout-wrapper">\
|
||||
<h1>Not Found</h1><br>\
|
||||
|
|
@ -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());});
|
||||
$(document).ready(function(){wn.versions.check();wn.provide('wn.app');$.extend(wn.app,new wn.Application());});
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
13
js/wn/dom.js
13
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;i<clist.length;i++) {
|
||||
var tmp = clist[i].split('=');
|
||||
cookies[strip(tmp[0])] = strip(tmp[1]);
|
||||
}
|
||||
return cookies[c];
|
||||
}
|
||||
|
||||
wn.dom.set_box_shadow = function(ele, spread) {
|
||||
|
|
|
|||
|
|
@ -35,6 +35,12 @@ wn.route = function() {
|
|||
}
|
||||
|
||||
wn.get_route = function(route) {
|
||||
// route for web
|
||||
if(!wn.boot) {
|
||||
return [window.page_name];
|
||||
}
|
||||
|
||||
// for app
|
||||
return $.map(wn.get_route_str(route).split('/'),
|
||||
function(r) { return decodeURIComponent(r); });
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
wn.provide('wn.views.pageview');
|
||||
|
||||
wn.views.pageview = {
|
||||
pages: {},
|
||||
with_page: function(name, callback) {
|
||||
if((locals.Page && locals.Page[name]) || name==window.home_page) {
|
||||
if((locals.Page && locals.Page[name]) || name==window.page_name) {
|
||||
callback();
|
||||
} else {
|
||||
wn.call({
|
||||
|
|
@ -14,12 +13,12 @@ wn.views.pageview = {
|
|||
}
|
||||
},
|
||||
show: function(name) {
|
||||
if(!name) name = (wn.boot ? wn.boot.home_page : 'Login Page');
|
||||
if(!name) name = (wn.boot ? wn.boot.home_page : window.page_name);
|
||||
wn.views.pageview.with_page(name, function(r) {
|
||||
if(r && r.exc) {
|
||||
if(!r['403'])wn.container.change_to('404');
|
||||
} else if(!wn.pages[name]) {
|
||||
wn.views.pageview.pages[name] = new wn.views.Page(name);
|
||||
new wn.views.Page(name);
|
||||
}
|
||||
wn.container.change_to(name);
|
||||
});
|
||||
|
|
@ -31,10 +30,11 @@ wn.views.Page = Class.extend({
|
|||
this.name = name;
|
||||
var me = this;
|
||||
// web home page
|
||||
if(name==window.home_page) {
|
||||
if(name==window.page_name) {
|
||||
this.wrapper = document.getElementById('page-' + name);
|
||||
this.wrapper.title = document.title;
|
||||
this.wrapper.label = window.home_page;
|
||||
this.wrapper.label = window.page_name;
|
||||
wn.pages[window.page_name] = this.wrapper;
|
||||
} else {
|
||||
this.pagedoc = locals.Page[this.name];
|
||||
this.wrapper = wn.container.add_page(this.name);
|
||||
|
|
@ -46,7 +46,7 @@ wn.views.Page = Class.extend({
|
|||
wn.dom.eval(this.pagedoc.__script || this.pagedoc.script || '');
|
||||
wn.dom.set_style(this.pagedoc.style || '');
|
||||
}
|
||||
|
||||
|
||||
this.trigger('onload');
|
||||
|
||||
// set events
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ def build():
|
|||
bundle = Bundle()
|
||||
bundle.make()
|
||||
update_version()
|
||||
import webnotes.cms
|
||||
webnotes.cms.make(get_version())
|
||||
import webnotes.cms.make
|
||||
webnotes.cms.make.make(get_version())
|
||||
|
||||
def get_version():
|
||||
"""get from version.num file and increment it"""
|
||||
|
|
|
|||
|
|
@ -99,6 +99,9 @@ class DocType:
|
|||
with open(path + '.css', 'w') as f:
|
||||
pass
|
||||
|
||||
# web page
|
||||
self.write_cms_page()
|
||||
|
||||
def get_from_files(self):
|
||||
"""
|
||||
Loads page info from files in module
|
||||
|
|
@ -131,11 +134,19 @@ class DocType:
|
|||
import webnotes.cms
|
||||
from jinja2 import Template
|
||||
|
||||
fname = webnotes.cms.page_name(self.doc.name) + '.html'
|
||||
if home_page:
|
||||
fname = 'index.html'
|
||||
|
||||
if self.doc.web_page=='Yes' or home_page:
|
||||
# doc will be dirty, so save it
|
||||
_doc = self.doc.fields.copy()
|
||||
|
||||
# load from files
|
||||
self.get_from_files()
|
||||
fname = webnotes.cms.page_name(self.doc.name) + '.html'
|
||||
|
||||
# home page?
|
||||
if self.doc.name==webnotes.cms.get_home_page('Guest'):
|
||||
fname = 'index.html'
|
||||
self.doc.web_page = 'Yes'
|
||||
|
||||
if not self.doc.title:
|
||||
self.doc.title = self.doc.name
|
||||
|
||||
|
|
@ -147,10 +158,9 @@ class DocType:
|
|||
self.doc.footer = startup.event_handlers.get_web_footer()
|
||||
|
||||
with open(fname, 'w') as page:
|
||||
with open('../lib/conf/index.html', 'r') as template:
|
||||
with open('../lib/conf/template.html', 'r') as template:
|
||||
t = Template(template.read())
|
||||
page.write(t.render(self.doc.fields))
|
||||
|
||||
del self.doc.fields['header']
|
||||
del self.doc.fields['footer']
|
||||
|
||||
|
||||
# back to original doc
|
||||
self.doc.fields = _doc
|
||||
|
|
@ -3,25 +3,26 @@
|
|||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2010-12-14 10:23:15',
|
||||
'creation': '2012-05-01 17:10:24',
|
||||
'docstatus': 0,
|
||||
'modified': '2010-12-24 13:59:56',
|
||||
'modified_by': 'Administrator',
|
||||
'owner': 'Administrator'
|
||||
'modified': '2012-05-08 12:54:22',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': 'Core',
|
||||
'module': u'Core',
|
||||
'name': '__common__',
|
||||
'page_name': 'Login Page',
|
||||
'standard': 'Yes'
|
||||
'page_name': u'Login Page',
|
||||
'standard': u'Yes',
|
||||
'web_page': u'Yes'
|
||||
},
|
||||
|
||||
# Page, Login Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': 'Login Page'
|
||||
'name': u'Login Page'
|
||||
}
|
||||
]
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<h1>Login Page</h1>
|
||||
|
||||
<p>Powered by Web Notes Framework</p>
|
||||
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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'
|
||||
|
|
@ -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 = """
|
||||
<header></header>
|
||||
<!-- Main Starts -->
|
||||
<div id="body_div">
|
||||
</div>
|
||||
<footer></footer>
|
||||
<div class="no_script" style="display: none;">
|
||||
%s
|
||||
</div>
|
||||
<div id="dialog_back"></div>
|
||||
"""
|
||||
|
||||
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 += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
|
||||
else:
|
||||
doc.footer_menu += '<li><a href="index.cgi#!%(std_page)s">%(label)s</a></li>' % m
|
||||
|
||||
return """
|
||||
<header>
|
||||
<h3>%(brand_html)s</h3>
|
||||
<ul>
|
||||
%(header_menu)s
|
||||
</ul>
|
||||
</header>
|
||||
%(content)s
|
||||
<footer>
|
||||
<ul>
|
||||
%(footer_menu)s
|
||||
</ul>
|
||||
<div>Address: %(address)s</div>
|
||||
<div>© %(copyright)s</div>
|
||||
<div>Powered by <a href="https://erpnext.com">erpnext.com</a></div>
|
||||
<div style="background-color: #ffc; padding: 7px">
|
||||
This page is for search engines, for standard browsers click
|
||||
<a href="index.cgi#!%(page_name)s">here</a>
|
||||
</div>
|
||||
</footer>
|
||||
""" % doc.fields
|
||||
|
||||
|
||||
45
py/webnotes/cms/make.py
Normal file
45
py/webnotes/cms/make.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
"""
|
||||
make index, wn.js, wn.css pages
|
||||
- rebuild all pages on change of website settings (toolbar)
|
||||
"""
|
||||
def make(version):
|
||||
import os
|
||||
import webnotes
|
||||
from webnotes.model.code import get_obj
|
||||
from jinja2 import Template
|
||||
from webnotes.cms import page_name, get_home_page
|
||||
|
||||
webnotes.connect()
|
||||
|
||||
# get web home
|
||||
home_page = get_home_page('Guest')
|
||||
|
||||
page = get_obj('Page', home_page)
|
||||
|
||||
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))
|
||||
|
||||
|
||||
|
|
@ -131,19 +131,6 @@ class Profile:
|
|||
self.can_read += self.can_write
|
||||
self.all_read += self.can_read
|
||||
|
||||
def get_home_page(self):
|
||||
"""
|
||||
Get the name of the user's home page from the `Control Panel`
|
||||
"""
|
||||
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(self.get_roles()))
|
||||
|
||||
if hpl:
|
||||
return hpl[0][0]
|
||||
else:
|
||||
return webnotes.conn.get_value('Control Panel',None,'home_page') or 'Login Page'
|
||||
|
||||
def get_defaults(self):
|
||||
"""
|
||||
Get the user's default values based on user and role profile
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue