cleaner web cache code
This commit is contained in:
parent
8790188fc8
commit
51146c07c3
@ -2,9 +2,12 @@ def execute():
|
|||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.model.sync
|
import webnotes.model.sync
|
||||||
|
|
||||||
# sync web page, blog doctype
|
# sync doctypes required for the patch
|
||||||
|
webnotes.model.sync.sync('website', 'web_cache')
|
||||||
webnotes.model.sync.sync('website', 'web_page')
|
webnotes.model.sync.sync('website', 'web_page')
|
||||||
webnotes.model.sync.sync('website', 'blog')
|
webnotes.model.sync.sync('website', 'blog')
|
||||||
|
webnotes.model.sync.sync('website', 'website_settings')
|
||||||
|
webnotes.model.sync.sync('stock', 'item')
|
||||||
|
|
||||||
cleanup()
|
cleanup()
|
||||||
|
|
||||||
@ -29,9 +32,29 @@ def cleanup():
|
|||||||
update `tabComment` comm, `tabBlog` blog
|
update `tabComment` comm, `tabBlog` blog
|
||||||
set comm.comment_doctype = 'Blog', comm.comment_docname = blog.name
|
set comm.comment_doctype = 'Blog', comm.comment_docname = blog.name
|
||||||
where comm.comment_docname = blog.page_name""")
|
where comm.comment_docname = blog.page_name""")
|
||||||
|
|
||||||
|
# delete deprecated pages
|
||||||
|
import webnotes.model
|
||||||
|
webnotes.model.delete_doc('Page', 'products')
|
||||||
|
webnotes.model.delete_doc('Page', 'contact')
|
||||||
|
webnotes.model.delete_doc('Page', 'blog')
|
||||||
|
webnotes.model.delete_doc('Page', 'about')
|
||||||
|
|
||||||
def save_pages():
|
def save_pages():
|
||||||
"""save all web pages, blogs to create content"""
|
"""save all web pages, blogs to create content"""
|
||||||
import website.web_cache
|
query_map = {
|
||||||
website.web_cache.rebuild_web_cache()
|
'Web Page': """select name from `tabWeb Page` where docstatus=0""",
|
||||||
|
'Blog': """\
|
||||||
|
select name from `tabBlog`
|
||||||
|
where docstatus = 0 and ifnull(published, 0) = 1""",
|
||||||
|
'Item': """\
|
||||||
|
select name from `tabItem`
|
||||||
|
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
|
||||||
|
}
|
||||||
|
|
||||||
|
import webnotes
|
||||||
|
from webnotes.model.doclist import DocList
|
||||||
|
|
||||||
|
for dt in query_map:
|
||||||
|
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||||
|
DocList(dt, result['name']).save()
|
||||||
@ -86,8 +86,7 @@ class DocType:
|
|||||||
def on_trash(self):
|
def on_trash(self):
|
||||||
sql("delete from tabBin where item_code='%s'"%(self.doc.item_code))
|
sql("delete from tabBin where item_code='%s'"%(self.doc.item_code))
|
||||||
|
|
||||||
import website.web_cache
|
self.delete_web_cache(self.doc.page_name)
|
||||||
website.web_cache.delete_web_cache(self.doc.page_name)
|
|
||||||
|
|
||||||
# Check whether Ref Rate is not entered twice for same Price List and Currency
|
# Check whether Ref Rate is not entered twice for same Price List and Currency
|
||||||
def check_ref_rate_detail(self):
|
def check_ref_rate_detail(self):
|
||||||
@ -224,17 +223,21 @@ Total Available Qty: %s
|
|||||||
def on_rename(self,newdn,olddn):
|
def on_rename(self,newdn,olddn):
|
||||||
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
|
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
|
||||||
|
|
||||||
def clear_web_cache(self):
|
def delete_web_cache(self, page_name):
|
||||||
import website.web_cache
|
import website.web_cache
|
||||||
|
website.web_cache.delete_cache(page_name)
|
||||||
|
|
||||||
|
def clear_web_cache(self):
|
||||||
if hasattr(self, 'old_page_name') and self.old_page_name and \
|
if hasattr(self, 'old_page_name') and self.old_page_name and \
|
||||||
self.doc.page_name != self.old_page_name:
|
self.doc.page_name != self.old_page_name:
|
||||||
website.web_cache.delete_web_cache(self.old_page_name)
|
self.delete_web_cache(self.doc.page_name)
|
||||||
|
|
||||||
if self.doc.show_in_website:
|
if self.doc.show_in_website:
|
||||||
website.web_cache.clear_web_cache(self.doc.doctype, self.doc.name, self.doc.page_name)
|
import website.web_cache
|
||||||
|
website.web_cache.create_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||||
|
website.web_cache.clear_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||||
else:
|
else:
|
||||||
website.web_cache.delete_web_cache(self.doc.page_name)
|
self.delete_web_cache(self.doc.page_name)
|
||||||
|
|
||||||
def update_page_name(self):
|
def update_page_name(self):
|
||||||
import website.utils
|
import website.utils
|
||||||
|
|||||||
@ -52,9 +52,8 @@ def add_comment(args=None):
|
|||||||
|
|
||||||
# since comments are embedded in the page, clear the web cache
|
# since comments are embedded in the page, clear the web cache
|
||||||
import website.web_cache
|
import website.web_cache
|
||||||
website.web_cache.clear_web_cache(
|
website.web_cache.clear_cache(args.get('page_name'),
|
||||||
args.get('comment_doctype'), args.get('comment_docname'),
|
args.get('comment_doctype'), args.get('comment_docname'))
|
||||||
args.get('page_name'))
|
|
||||||
|
|
||||||
import webnotes.utils
|
import webnotes.utils
|
||||||
|
|
||||||
@ -62,7 +61,7 @@ def add_comment(args=None):
|
|||||||
template_args = { 'comment_list': [comment] }
|
template_args = { 'comment_list': [comment] }
|
||||||
|
|
||||||
# get html of comment row
|
# get html of comment row
|
||||||
comment_html = website.web_cache.build_html(template_args, 'blog/comment.html')
|
comment_html = website.web_cache.build_html(template_args, 'html/comment.html')
|
||||||
|
|
||||||
return comment_html
|
return comment_html
|
||||||
|
|
||||||
@ -28,43 +28,17 @@ class DocType:
|
|||||||
self.validate_domain_list()
|
self.validate_domain_list()
|
||||||
|
|
||||||
def on_update(self):
|
def on_update(self):
|
||||||
self.rewrite_pages()
|
# make js and css
|
||||||
|
|
||||||
from webnotes.session_cache import clear_cache
|
|
||||||
clear_cache('Guest')
|
|
||||||
|
|
||||||
def rewrite_pages(self):
|
|
||||||
"""rewrite all web pages"""
|
|
||||||
import webnotes
|
|
||||||
from webnotes.model.doclist import DocList
|
|
||||||
from webnotes.model.code import get_obj
|
|
||||||
|
|
||||||
# rewrite all web pages
|
|
||||||
for name in webnotes.conn.sql("""select name, modified from `tabWeb Page`
|
|
||||||
where docstatus=0"""):
|
|
||||||
DocList('Web Page', name[0]).save()
|
|
||||||
webnotes.conn.set_value('Web Page', name[0], 'modified', name[1])
|
|
||||||
|
|
||||||
# rewrite all blog pages
|
|
||||||
for name in webnotes.conn.sql("""select name, modified from `tabBlog`
|
|
||||||
where docstatus=0 and ifnull(published,0)=1"""):
|
|
||||||
DocList('Blog', name[0]).save()
|
|
||||||
webnotes.conn.set_value('Blog', name[0], 'modified', name[1])
|
|
||||||
|
|
||||||
from webnotes.cms.make import make_web_core
|
from webnotes.cms.make import make_web_core
|
||||||
make_web_core()
|
make_web_core()
|
||||||
|
|
||||||
|
# clear web cache
|
||||||
import website.web_cache
|
import website.web_cache
|
||||||
for page in ['blog', 'products']:
|
website.web_cache.refresh_cache()
|
||||||
website.web_cache.delete_web_cache(page)
|
|
||||||
website.web_cache.clear_web_cache(None, None, page)
|
|
||||||
|
|
||||||
#get_obj('Page', 'blog').write_cms_page(force=True)
|
|
||||||
#get_obj('Page', 'Login Page').write_cms_page(force=True)
|
|
||||||
|
|
||||||
webnotes.msgprint('Rebuilt all blogs and pages')
|
|
||||||
|
|
||||||
|
|
||||||
|
from webnotes.session_cache import clear_cache
|
||||||
|
clear_cache('Guest')
|
||||||
|
|
||||||
def set_home_page(self):
|
def set_home_page(self):
|
||||||
|
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|||||||
@ -1,34 +0,0 @@
|
|||||||
// ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
erpnext.make_product_categories = function(wrapper) {
|
|
||||||
wrapper.category_list = new wn.ui.Listing({
|
|
||||||
parent: $(wrapper).find('.more-categories').get(0),
|
|
||||||
query: 'select count(name) as items, item_group \
|
|
||||||
from tabItem \
|
|
||||||
where is_sales_item="Yes" and \
|
|
||||||
ifnull(show_in_website, "No")="Yes" and \
|
|
||||||
docstatus = 0 \
|
|
||||||
group by item_group order by items desc',
|
|
||||||
hide_refresh: true,
|
|
||||||
render_row: function(parent, data) {
|
|
||||||
parent.innerHTML = repl('<a href="#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
|
|
||||||
data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
wrapper.category_list.run();
|
|
||||||
console.log('product categories made');
|
|
||||||
}
|
|
||||||
@ -1,130 +0,0 @@
|
|||||||
// ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
wn.provide('erpnext.navbar');
|
|
||||||
|
|
||||||
/*
|
|
||||||
<li class="dropdown">\
|
|
||||||
<a class="dropdown-toggle" href="#" onclick="return false;"></a>\
|
|
||||||
<ul class="dropdown-menu" id="toolbar-user">\
|
|
||||||
</ul>\
|
|
||||||
</li>\
|
|
||||||
*/
|
|
||||||
|
|
||||||
erpnext.navbar.Navbar = Class.extend({
|
|
||||||
init: function() {
|
|
||||||
this.make();
|
|
||||||
$('.brand').html(wn.boot.website_settings.brand_html || sys_defaults.company);
|
|
||||||
this.make_items();
|
|
||||||
$('.dropdown-toggle').dropdown();
|
|
||||||
},
|
|
||||||
make: function() {
|
|
||||||
$('header').append('<div class="navbar navbar-fixed-top">\
|
|
||||||
<div class="navbar-inner">\
|
|
||||||
<div class="container">\
|
|
||||||
<a class="brand">[brand]</a>\
|
|
||||||
<ul class="nav">\
|
|
||||||
</ul>\
|
|
||||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>\
|
|
||||||
<ul class="nav pull-right">\
|
|
||||||
<li id="login-topbar-item"><a href="#!Login Page">Login</a></li>\
|
|
||||||
</ul>\
|
|
||||||
</div>\
|
|
||||||
</div>\
|
|
||||||
</div>');
|
|
||||||
$('.brand').attr('href', '#!' + (wn.boot.website_settings.home_page || 'Login Page'))
|
|
||||||
},
|
|
||||||
make_items: function() {
|
|
||||||
var items = wn.boot.website_menus;
|
|
||||||
|
|
||||||
// parent labels
|
|
||||||
for(var i=0;i<items.length;i++) {
|
|
||||||
var item = items[i];
|
|
||||||
if(!item.parent_label && item.parentfield=='top_bar_items') {
|
|
||||||
erpnext.header_link_settings(item);
|
|
||||||
$('header .nav:first').append(repl('<li data-label="%(label)s">\
|
|
||||||
<a href="%(route)s" %(target)s>%(label)s</a></li>', item));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// child labels
|
|
||||||
for(var i=0;i<items.length;i++) {
|
|
||||||
var item = items[i];
|
|
||||||
if(item.parent_label && item.parentfield=='top_bar_items') {
|
|
||||||
// check if parent label has class "dropdown"
|
|
||||||
$parent_li = $(repl('header li[data-label="%(parent_label)s"]', item));
|
|
||||||
if(!$parent_li.hasClass('dropdown')) {
|
|
||||||
$parent_li.addClass('dropdown');
|
|
||||||
$parent_li.find('a:first').addClass('dropdown-toggle')
|
|
||||||
.attr('data-toggle', 'dropdown')
|
|
||||||
.attr('href', '')
|
|
||||||
.append('<b class="caret"></b>')
|
|
||||||
.click(function() {
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$parent_li.append('');
|
|
||||||
}
|
|
||||||
erpnext.header_link_settings(item);
|
|
||||||
$parent_li.find('.dropdown-menu').append(repl('<li data-label="%(label)s">\
|
|
||||||
<a href="%(route)s" %(target)s>%(label)s</a></li>', item))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// footer
|
|
||||||
erpnext.Footer = Class.extend({
|
|
||||||
init: function() {
|
|
||||||
if(!wn.boot.website_settings.copyright) {
|
|
||||||
wn.boot.website_settings.copyright = sys_defaults.company;
|
|
||||||
}
|
|
||||||
if(!wn.boot.website_settings.address) {
|
|
||||||
wn.boot.website_settings.address = '';
|
|
||||||
}
|
|
||||||
$('footer').html(repl('<div class="web-footer">\
|
|
||||||
<div class="web-footer-menu"><ul></ul></div>\
|
|
||||||
<div class="web-footer-copyright">© %(copyright)s</div>\
|
|
||||||
</div>', wn.boot.website_settings));
|
|
||||||
this.make_items();
|
|
||||||
},
|
|
||||||
make_items: function() {
|
|
||||||
var items = wn.boot.website_menus
|
|
||||||
for(var i=0;i<items.length;i++) {
|
|
||||||
var item = items[i];
|
|
||||||
if(!item.parent_label && item.parentfield=='footer_items') {
|
|
||||||
erpnext.header_link_settings(item);
|
|
||||||
$('.web-footer-menu ul').append(repl('<li><a href="%(route)s" %(target)s\
|
|
||||||
data-label="%(label)s">%(label)s</a></li>', item))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// customize hard / soft links
|
|
||||||
erpnext.header_link_settings = function(item) {
|
|
||||||
item.route = item.url || item.custom_page;
|
|
||||||
if(item.route && item.route.substr(0,4)=='http') {
|
|
||||||
item.target = 'target="_blank"';
|
|
||||||
} else {
|
|
||||||
item.target = '';
|
|
||||||
item.route = '#!' + item.route;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(document).bind('startup', function() {
|
|
||||||
erpnext.footer = new erpnext.Footer();
|
|
||||||
//erpnext.navbar.navbar = new erpnext.navbar.Navbar();
|
|
||||||
})
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
# Page, about
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-01-27 11:37:57',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-01-27 13:26:42',
|
|
||||||
'modified_by': 'Administrator',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'module': 'Website',
|
|
||||||
'name': '__common__',
|
|
||||||
'page_name': 'about',
|
|
||||||
'standard': 'Yes',
|
|
||||||
'title': 'About Us'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'about',
|
|
||||||
'parentfield': 'roles',
|
|
||||||
'parenttype': 'Page',
|
|
||||||
'role': 'Guest'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page, about
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'name': 'about'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,23 +0,0 @@
|
|||||||
<div class="layout-wrapper layout-wrapper-background">
|
|
||||||
<div class="web-content" id="content-blog">
|
|
||||||
<div class="layout-main-section">
|
|
||||||
<h1>Blog</h1>
|
|
||||||
<br>
|
|
||||||
<div id="blog-list"></div>
|
|
||||||
</div>
|
|
||||||
<div class="layout-side-section">
|
|
||||||
<!-- for later
|
|
||||||
<h4>Get Updates</h4>
|
|
||||||
<p>
|
|
||||||
<input name="blog-subscribe">
|
|
||||||
<button class="btn" id="blog-subscribe">Subscribe</button>
|
|
||||||
</p>-->
|
|
||||||
<h4>Subscribe</h4>
|
|
||||||
<p>
|
|
||||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
|
||||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div style="clear: both"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@ -1,59 +0,0 @@
|
|||||||
// ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
|
|
||||||
pscript.onload_blog = function(wrapper) {
|
|
||||||
wrapper.blog_list = new wn.ui.Listing({
|
|
||||||
parent: $(wrapper).find('#blog-list').get(0),
|
|
||||||
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
|
|
||||||
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
|
|
||||||
from tabProfile, tabBlog\
|
|
||||||
where ifnull(published,0)=1 and tabBlog.owner = tabProfile.name \
|
|
||||||
order by tabBlog.creation desc',
|
|
||||||
hide_refresh: true,
|
|
||||||
no_toolbar: true,
|
|
||||||
render_row: function(parent, data) {
|
|
||||||
if(data.content && data.content.length==1000) data.content += '... (read on)';
|
|
||||||
data.content = wn.markdown(data.content);
|
|
||||||
if(data.last_name) data.last_name = ' ' + data.last_name;
|
|
||||||
data.date = prettyDate(data.creation);
|
|
||||||
parent.innerHTML = repl('<h2>%(title)s</h2>\
|
|
||||||
<p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
|
|
||||||
<p>%(content)s</p>\
|
|
||||||
<a href="%(name)s.html">Read Full Text</a><br>', data);
|
|
||||||
},
|
|
||||||
page_length: 10
|
|
||||||
});
|
|
||||||
wrapper.blog_list.run();
|
|
||||||
|
|
||||||
// subscribe button
|
|
||||||
$('#blog-subscribe').click(function() {
|
|
||||||
var email = $(wrapper).find('input[name="blog-subscribe"]').val();
|
|
||||||
if(!validate_email(email)) {
|
|
||||||
msgprint('Please enter a valid email!');
|
|
||||||
}
|
|
||||||
wn.call({
|
|
||||||
module:'website',
|
|
||||||
page:'blog',
|
|
||||||
method:'subscribe',
|
|
||||||
args:email,
|
|
||||||
btn: this,
|
|
||||||
callback: function() {
|
|
||||||
$(wrapper).find('input[name="blog-subscribe"]').val('');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
# ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import webnotes
|
|
||||||
|
|
||||||
@webnotes.whitelist()
|
|
||||||
def subscribe(arg):
|
|
||||||
"""subscribe to blog (blog_subscriber)"""
|
|
||||||
if webnotes.conn.sql("""select name from `tabBlog Subscriber` where name=%s""", arg):
|
|
||||||
webnotes.msgprint("Already a subscriber. Thanks!")
|
|
||||||
else:
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
d = Document('Blog Subscriber')
|
|
||||||
d.name = arg
|
|
||||||
d.save()
|
|
||||||
webnotes.msgprint("Thank you for subscribing!")
|
|
||||||
@ -1,44 +0,0 @@
|
|||||||
# Page, blog
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-01-27 15:47:52',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-01-27 15:47:52',
|
|
||||||
'modified_by': 'Administrator',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'module': 'Website',
|
|
||||||
'name': '__common__',
|
|
||||||
'page_name': 'blog',
|
|
||||||
'standard': 'Yes',
|
|
||||||
'title': 'Blog'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page Role
|
|
||||||
{
|
|
||||||
'__islocal': 1,
|
|
||||||
'doctype': 'Page Role',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'blog',
|
|
||||||
'parentfield': 'roles',
|
|
||||||
'parenttype': 'Page',
|
|
||||||
'role': 'Guest'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page, blog
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'name': 'blog'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,46 +0,0 @@
|
|||||||
// ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
pscript.onload_contact = function(wrapper) {
|
|
||||||
$('#content-contact-us .btn.primary').click(function() {
|
|
||||||
var me = this;
|
|
||||||
var args = {};
|
|
||||||
args.name = $('#content-contact-us [name="contact-name"]').val();
|
|
||||||
args.email = $('#content-contact-us [name="contact-email"]').val();
|
|
||||||
args.message = $('#content-contact-us [name="contact-message"]').val();
|
|
||||||
|
|
||||||
if(!validate_email(args.email)) {
|
|
||||||
msgprint('Please enter a valid email id');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(args.name && args.email && args.message) {
|
|
||||||
$(this).set_working();
|
|
||||||
$c_page('website', 'contact', 'send', args, function(r) {
|
|
||||||
$('#content-contact-us [name*="contact"]').val('');
|
|
||||||
$(me).done_working();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
msgprint("Please enter info in all the fields.")
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#content-contact-us :input').keyup(function(ev) {
|
|
||||||
if(ev.which == 13) {
|
|
||||||
$('#content-contact-us .btn.primary').click();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@ -1,32 +0,0 @@
|
|||||||
# ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import json, webnotes
|
|
||||||
|
|
||||||
@webnotes.whitelist(allow_guest=True)
|
|
||||||
def send(args):
|
|
||||||
"""create support ticket"""
|
|
||||||
args = json.loads(args)
|
|
||||||
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
d = Document('Support Ticket')
|
|
||||||
d.raised_by = args['email']
|
|
||||||
d.description = 'From: ' + args['name'] + '\n\n' + args['message']
|
|
||||||
d.subject = 'Website Query'
|
|
||||||
d.status = 'Open'
|
|
||||||
d.owner = 'Guest'
|
|
||||||
d.save(1)
|
|
||||||
webnotes.msgprint("Thank you for your query. We will respond as soon as we can.")
|
|
||||||
@ -1,42 +0,0 @@
|
|||||||
# Page, contact
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-01-25 16:02:15',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-01-25 16:02:15',
|
|
||||||
'modified_by': 'Administrator',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'module': 'Website',
|
|
||||||
'name': '__common__',
|
|
||||||
'page_name': 'contact',
|
|
||||||
'standard': 'Yes'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'contact',
|
|
||||||
'parentfield': 'roles',
|
|
||||||
'parenttype': 'Page',
|
|
||||||
'role': 'Guest'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page, contact
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'name': 'contact'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
@ -1,27 +0,0 @@
|
|||||||
## Products
|
|
||||||
|
|
||||||
Contains
|
|
||||||
|
|
||||||
- List of Products tagged by Item master
|
|
||||||
- image
|
|
||||||
- short description (md)
|
|
||||||
- pricing info (if public) (public pricelist)
|
|
||||||
- stock info (website warehouse)
|
|
||||||
- Search
|
|
||||||
- Sidebar contains categories (# of items in each category)
|
|
||||||
|
|
||||||
When Item is Saved, a page for that item is created with
|
|
||||||
|
|
||||||
- Large image
|
|
||||||
- Smaller images
|
|
||||||
- Long Description
|
|
||||||
- Pricing info
|
|
||||||
- Stock info
|
|
||||||
- Contact Button (instead of Buy / Add to cart)
|
|
||||||
|
|
||||||
### Steps
|
|
||||||
|
|
||||||
- update item master
|
|
||||||
- update item category (show in web + priority) (or in a products settings page)
|
|
||||||
- # of public items in each category
|
|
||||||
- validation - item cannot have show in item if parent does not have it
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
<div class="layout-wrapper layout-wrapper-background" id="content-products">
|
|
||||||
<div class="layout-main-section">
|
|
||||||
<h1 class="products-category"></h1>
|
|
||||||
<div class="products-search" style="margin-bottom: 15px;">
|
|
||||||
<input name="products-search" /><button class="btn" style="margin-left: 7px">Search</button>
|
|
||||||
</div>
|
|
||||||
<div class="products-list"></div>
|
|
||||||
</div>
|
|
||||||
<div class="layout-side-section">
|
|
||||||
<h3>Categories</h3>
|
|
||||||
<div class="more-categories"></div>
|
|
||||||
</div>
|
|
||||||
<div style="clear:both;">
|
|
||||||
</div>
|
|
||||||
@ -1,109 +0,0 @@
|
|||||||
// ERPNext - web based ERP (http://erpnext.com)
|
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
|
||||||
//
|
|
||||||
// This program is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// This program is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
erpnext.products = {}
|
|
||||||
|
|
||||||
wn.require('js/product_category.js');
|
|
||||||
|
|
||||||
pscript.onload_products = function(wrapper) {
|
|
||||||
erpnext.make_product_categories(wrapper);
|
|
||||||
erpnext.products.wrapper = wrapper;
|
|
||||||
|
|
||||||
// make lists
|
|
||||||
erpnext.products.make_product_list(wrapper);
|
|
||||||
|
|
||||||
// button
|
|
||||||
$(wrapper).find('.products-search .btn').click(function() {
|
|
||||||
wrapper.mainlist.run();
|
|
||||||
});
|
|
||||||
|
|
||||||
$(wrapper).find('.products-search input').keypress(function(ev) {
|
|
||||||
if(ev.which==13) $(wrapper).find('.products-search .btn').click();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
pscript.onshow_products = function(wrapper) {
|
|
||||||
// show default product category
|
|
||||||
erpnext.products.set_group();
|
|
||||||
}
|
|
||||||
|
|
||||||
erpnext.products.get_group = function() {
|
|
||||||
route = wn.get_route();
|
|
||||||
if(route.length>1) {
|
|
||||||
// from url
|
|
||||||
var grp = route[1];
|
|
||||||
var label = route[1];
|
|
||||||
} else {
|
|
||||||
// default
|
|
||||||
var grp = wn.boot.website_settings.default_product_category;
|
|
||||||
var label = wn.boot.website_settings.default_product_category;
|
|
||||||
}
|
|
||||||
erpnext.products.cur_group = grp;
|
|
||||||
return {grp:grp, label:label};
|
|
||||||
}
|
|
||||||
|
|
||||||
erpnext.products.make_product_list = function(wrapper) {
|
|
||||||
wrapper.mainlist = new wn.ui.Listing({
|
|
||||||
parent: $(wrapper).find('.products-list').get(0),
|
|
||||||
run_btn: $(wrapper).find('.products-search .btn').get(0),
|
|
||||||
no_toolbar: true,
|
|
||||||
get_query: function() {
|
|
||||||
var srch = $('input[name="products-search"]').val()
|
|
||||||
var search_cond = 'and (description like "%%(srch)s%"\
|
|
||||||
or item_name like "%%(srch)s%")';
|
|
||||||
args = {
|
|
||||||
search_cond: srch ? repl(search_cond, {srch:srch}) : '',
|
|
||||||
cat: erpnext.products.cur_group
|
|
||||||
};
|
|
||||||
return repl('select name, item_name, website_image, \
|
|
||||||
description, page_name \
|
|
||||||
from tabItem \
|
|
||||||
where is_sales_item="Yes" \
|
|
||||||
and item_group="%(cat)s" \
|
|
||||||
%(search_cond)s', args)
|
|
||||||
},
|
|
||||||
render_row: function(parent, data) {
|
|
||||||
parent.innerHTML = repl('<div style="float:left; width: 115px;" class="img-area">\
|
|
||||||
</div>\
|
|
||||||
<div style="float:left; width: 400px">\
|
|
||||||
<p><b><a href="#!%(page_name)s">%(item_name)s</a></b></p>\
|
|
||||||
<p>%(description)s</p></div>\
|
|
||||||
<div style="clear: both;"></div>', data);
|
|
||||||
|
|
||||||
if(data.website_image) {
|
|
||||||
$(parent).find('.img-area').append(repl(
|
|
||||||
'<img src="files/%(website_image)s" style="width:100px;">', data))
|
|
||||||
} else {
|
|
||||||
$(parent).find('.img-area').append(wn.dom.placeholder(70,
|
|
||||||
data.item_name));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
erpnext.products.set_group = function() {
|
|
||||||
var cat = erpnext.products.get_group();
|
|
||||||
if(!cat.grp) {
|
|
||||||
// still nothing
|
|
||||||
setTimeout('erpnext.products.set_group()', 1000);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// get erpnext.products.default_category
|
|
||||||
var wrapper = erpnext.products.wrapper;
|
|
||||||
|
|
||||||
$(wrapper).find('h1').html(cat.label);
|
|
||||||
wrapper.mainlist.run();
|
|
||||||
}
|
|
||||||
@ -1,43 +0,0 @@
|
|||||||
# Page, products
|
|
||||||
[
|
|
||||||
|
|
||||||
# These values are common in all dictionaries
|
|
||||||
{
|
|
||||||
'creation': '2012-01-30 10:49:01',
|
|
||||||
'docstatus': 0,
|
|
||||||
'modified': '2012-01-30 10:49:01',
|
|
||||||
'modified_by': 'Administrator',
|
|
||||||
'owner': 'Administrator'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'module': 'Website',
|
|
||||||
'name': '__common__',
|
|
||||||
'page_name': 'products',
|
|
||||||
'standard': 'Yes',
|
|
||||||
'title': 'Products'
|
|
||||||
},
|
|
||||||
|
|
||||||
# These values are common for all Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role',
|
|
||||||
'name': '__common__',
|
|
||||||
'parent': 'products',
|
|
||||||
'parentfield': 'roles',
|
|
||||||
'parenttype': 'Page',
|
|
||||||
'role': 'Guest'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page, products
|
|
||||||
{
|
|
||||||
'doctype': 'Page',
|
|
||||||
'name': 'products'
|
|
||||||
},
|
|
||||||
|
|
||||||
# Page Role
|
|
||||||
{
|
|
||||||
'doctype': 'Page Role'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
7
erpnext/website/templates/css/blog.css
Normal file
7
erpnext/website/templates/css/blog.css
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<style>
|
||||||
|
h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
|
||||||
|
h2 > a:hover, h2 > a:focus {
|
||||||
|
text-decoration: none;
|
||||||
|
color: inherit;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
9
erpnext/website/templates/css/blog_page.css
Normal file
9
erpnext/website/templates/css/blog_page.css
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<style>
|
||||||
|
.comment-title {
|
||||||
|
color:#777;
|
||||||
|
}
|
||||||
|
|
||||||
|
.comment-content {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
10
erpnext/website/templates/css/login.css
Normal file
10
erpnext/website/templates/css/login.css
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<style>
|
||||||
|
#login_wrapper {
|
||||||
|
width: 300px !important;
|
||||||
|
margin: 20px auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.login-banner {
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
34
erpnext/website/templates/css/product_page.css
Normal file
34
erpnext/website/templates/css/product_page.css
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<style>
|
||||||
|
.web-long-description {
|
||||||
|
font-size: 18px;
|
||||||
|
line-height: 200%;
|
||||||
|
}
|
||||||
|
.product-page-content {
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
/* product page image css */
|
||||||
|
.product-page-content img {
|
||||||
|
max-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* similar products listing */
|
||||||
|
.similar-products .img-area img {
|
||||||
|
max-width: 55px;
|
||||||
|
max-height: 55px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.similar-products .img-area {
|
||||||
|
float: left;
|
||||||
|
width: 30%;
|
||||||
|
margin-top: 0.3em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.similar-product-description {
|
||||||
|
float: left;
|
||||||
|
width: 70%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.similar-product-description span {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
11
erpnext/website/templates/css/products.css
Normal file
11
erpnext/website/templates/css/products.css
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<style>
|
||||||
|
.img-area {
|
||||||
|
float:left;
|
||||||
|
width: 115px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-list-description {
|
||||||
|
float:left;
|
||||||
|
width: 400px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -1,26 +1,41 @@
|
|||||||
{% extends "blog/blog.js" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{% include "js/blog_page.js" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{% include "css/blog_page.css" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="layout-wrapper layout-wrapper-background">
|
<div class="layout-wrapper layout-wrapper-background">
|
||||||
<div class="web-content" id="blog-{{ name }}">
|
<div class="web-content" id="blog-{{ name }}">
|
||||||
|
|
||||||
<div class="layout-main-section">
|
<div class="layout-main-section">
|
||||||
|
|
||||||
<h2>{{ title }}</h2>
|
<h2>{{ title }}</h2>
|
||||||
|
|
||||||
|
<!-- begin blog content -->
|
||||||
<div class="help">By {{ full_name }} on {{ updated }}</div>
|
<div class="help">By {{ full_name }} on {{ updated }}</div>
|
||||||
<br>
|
<br>
|
||||||
{{ content_html }}
|
{{ content_html }}
|
||||||
<hr>
|
<hr>
|
||||||
<h3>Comments</h3><br>
|
<h3>Comments</h3><br>
|
||||||
<div class="blog-comments">
|
<div class="blog-comments">
|
||||||
|
|
||||||
|
{% if not comment_list %}
|
||||||
<div class="no-result help hide">
|
<div class="no-result help hide">
|
||||||
<p>Be the first one to comment</p>
|
<p>Be the first one to comment</p>
|
||||||
<br />
|
<br />
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% include 'blog/comment.html' %}
|
|
||||||
|
{% include 'html/comment.html' %}
|
||||||
<button class="btn add-comment">Add Comment</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
<!-- end blog content -->
|
||||||
|
|
||||||
|
<button class="btn add-comment">Add Comment</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="layout-side-section">
|
<div class="layout-side-section">
|
||||||
@ -39,21 +54,4 @@
|
|||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
<style>
|
|
||||||
.comment-title {
|
|
||||||
color:#777;
|
|
||||||
}
|
|
||||||
|
|
||||||
.comment-content {
|
|
||||||
margin-left: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* .comment-row {
|
|
||||||
padding: 5px 0px;
|
|
||||||
}
|
|
||||||
*/ </style>
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -2,7 +2,7 @@
|
|||||||
requires, brand, top_bar_items, footer_items, copyright, content
|
requires, brand, top_bar_items, footer_items, copyright, content
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{% extends "base.html" %}
|
{% extends "html/base.html" %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
@ -31,7 +31,7 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
||||||
<ul class="nav pull-right">
|
<ul class="nav pull-right">
|
||||||
<li id="login-topbar-item"><a href="login-page.html">Login</a></li>
|
<li id="login-topbar-item"><a href="login.html">Login</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -50,7 +50,9 @@
|
|||||||
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul></div>
|
</ul></div>
|
||||||
|
{% if copyright %}
|
||||||
<div class="web-footer-copyright">© {{ copyright }}
|
<div class="web-footer-copyright">© {{ copyright }}
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
@ -1,10 +1,9 @@
|
|||||||
{% extends "outer.html" %}
|
{% extends "html/outer.html" %}
|
||||||
|
|
||||||
{% block title %}{{ title }}{% endblock %}
|
{% block title %}{{ title }}{% endblock %}
|
||||||
|
|
||||||
{% block header %}
|
{% block header %}
|
||||||
{{ super() }}
|
{{ super() }}
|
||||||
{% if insert_code %}
|
|
||||||
<script>
|
<script>
|
||||||
window.page_name = "{{ name }}";
|
window.page_name = "{{ name }}";
|
||||||
|
|
||||||
@ -13,7 +12,6 @@
|
|||||||
|
|
||||||
// page script
|
// page script
|
||||||
{% block javascript %}
|
{% block javascript %}
|
||||||
{{ javascript }}
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
// trigger onload
|
// trigger onload
|
||||||
@ -23,7 +21,6 @@
|
|||||||
wn.container.change_to(window.page_name);
|
wn.container.change_to(window.page_name);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
{% if insert_style %}
|
{% if insert_style %}
|
||||||
@ -1,4 +1,12 @@
|
|||||||
{% extends "product/product.js" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{% include "js/product_page.js" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{% include "css/product_page.css" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
{% if item_name != name %}
|
{% if item_name != name %}
|
||||||
@ -37,41 +45,4 @@
|
|||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
<style>
|
|
||||||
.web-long-description {
|
|
||||||
font-size: 18px;
|
|
||||||
line-height: 200%;
|
|
||||||
}
|
|
||||||
.product-page-content {
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
/* product page image css */
|
|
||||||
.product-page-content img {
|
|
||||||
max-width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* similar products listing */
|
|
||||||
.similar-products .img-area img {
|
|
||||||
max-width: 55px;
|
|
||||||
max-height: 55px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.similar-products .img-area {
|
|
||||||
float: left;
|
|
||||||
width: 30%;
|
|
||||||
margin-top: 0.3em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.similar-product-description {
|
|
||||||
float: left;
|
|
||||||
width: 70%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.similar-product-description span {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,4 +1,10 @@
|
|||||||
{% extends "page.html" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{% if insert_code %}
|
||||||
|
{{ javascript }}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="layout-wrapper layout-wrapper-background">
|
<div class="layout-wrapper layout-wrapper-background">
|
||||||
@ -1,6 +1,3 @@
|
|||||||
{% extends "page.html" %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
|
||||||
// ERPNext - web based ERP (http://erpnext.com)
|
// ERPNext - web based ERP (http://erpnext.com)
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
//
|
//
|
||||||
@ -43,6 +40,4 @@ wn.pages['{{ name }}'].onload = function(wrapper) {
|
|||||||
page_length: 10
|
page_length: 10
|
||||||
});
|
});
|
||||||
erpnext.blog_list.run();
|
erpnext.blog_list.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,6 +1,3 @@
|
|||||||
{% extends "page.html" %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
|
||||||
// ERPNext - web based ERP (http://erpnext.com)
|
// ERPNext - web based ERP (http://erpnext.com)
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
//
|
//
|
||||||
@ -18,6 +15,7 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// js inside blog page
|
// js inside blog page
|
||||||
|
|
||||||
wn.provide('erpnext.blog');
|
wn.provide('erpnext.blog');
|
||||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||||
erpnext.blog.wrapper = wrapper;
|
erpnext.blog.wrapper = wrapper;
|
||||||
@ -79,6 +77,7 @@ erpnext.blog.toggle_no_result = function(wrapper) {
|
|||||||
var $blog_comments = $(wrapper).find('.blog-comments');
|
var $blog_comments = $(wrapper).find('.blog-comments');
|
||||||
var $comment_rows = $blog_comments.find('.comment-row');
|
var $comment_rows = $blog_comments.find('.comment-row');
|
||||||
var $no_result = $blog_comments.find('.no-result');
|
var $no_result = $blog_comments.find('.no-result');
|
||||||
|
|
||||||
if ($comment_rows.length == 0) {
|
if ($comment_rows.length == 0) {
|
||||||
$no_result.removeClass('hide');
|
$no_result.removeClass('hide');
|
||||||
} else {
|
} else {
|
||||||
@ -156,9 +155,9 @@ erpnext.blog.add_comment_to_page = function(wrapper, comment) {
|
|||||||
$comment_rows = $blog_comments.find('.comment-row');
|
$comment_rows = $blog_comments.find('.comment-row');
|
||||||
|
|
||||||
if ($comment_rows.length) {
|
if ($comment_rows.length) {
|
||||||
$comment_rows.last().after(comment);
|
$blog_comments.append(comment);
|
||||||
} else {
|
} else {
|
||||||
$blog_comments.find('.no-result').after(comment);
|
$blog_comments.append(comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
erpnext.blog.toggle_no_result(wrapper);
|
erpnext.blog.toggle_no_result(wrapper);
|
||||||
@ -170,7 +169,12 @@ erpnext.blog.toggle_add_comment_btn = function(wrapper) {
|
|||||||
if ($wrapper.find('.blog-comments .comment-row').length > 50) {
|
if ($wrapper.find('.blog-comments .comment-row').length > 50) {
|
||||||
var $comment_btn = $wrapper.find('button.add-comment');
|
var $comment_btn = $wrapper.find('button.add-comment');
|
||||||
$comment_btn.addClass('hide');
|
$comment_btn.addClass('hide');
|
||||||
|
|
||||||
|
// show comments are close
|
||||||
|
$wrapper.find('.blog-comments').append("\
|
||||||
|
<div class=\"help\"> \
|
||||||
|
<p>Comments Closed</p> \
|
||||||
|
<br /> \
|
||||||
|
</div>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,28 +1,18 @@
|
|||||||
{% extends "page.html" %}
|
// ERPNext - web based ERP (http://erpnext.com)
|
||||||
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
{% block javascript %}
|
|
||||||
{{ super() }}
|
|
||||||
// Copyright (c) 2012 Web Notes Technologies Pvt Ltd (http://erpnext.com)
|
|
||||||
//
|
//
|
||||||
// MIT License (MIT)
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// This program is distributed in the hope that it will be useful,
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
// to deal in the Software without restriction, including without limitation
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
// GNU General Public License for more details.
|
||||||
// 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.
|
|
||||||
//
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
wn.provide('erpnext.login');
|
wn.provide('erpnext.login');
|
||||||
|
|
||||||
@ -98,6 +88,4 @@ erpnext.login.show_forgot_password = function(){
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
d.show();
|
d.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,7 +1,5 @@
|
|||||||
{% extends "page.html" %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
|
||||||
wn.provide('erpnext.products');
|
wn.provide('erpnext.products');
|
||||||
|
|
||||||
erpnext.products.make_product_categories = function(wrapper) {
|
erpnext.products.make_product_categories = function(wrapper) {
|
||||||
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
if (!wrapper) { wrapper = erpnext.products.wrapper; }
|
||||||
if (!wrapper) { return; }
|
if (!wrapper) { return; }
|
||||||
@ -17,6 +15,4 @@ erpnext.products.make_product_categories = function(wrapper) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
wrapper.category_list.run();
|
wrapper.category_list.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,7 +1,3 @@
|
|||||||
{% extends "product/product_category.js" %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
|
||||||
{{ super() }}
|
|
||||||
// ERPNext - web based ERP (http://erpnext.com)
|
// ERPNext - web based ERP (http://erpnext.com)
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
//
|
//
|
||||||
@ -17,7 +13,9 @@
|
|||||||
//
|
//
|
||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
wn.provide('erpnext.products');
|
|
||||||
|
{% include "js/product_category.js" %}
|
||||||
|
|
||||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||||
wrapper.product_group = "{{ item_group }}";
|
wrapper.product_group = "{{ item_group }}";
|
||||||
wrapper.product_name = "{{ name }}";
|
wrapper.product_name = "{{ name }}";
|
||||||
@ -91,6 +89,4 @@ erpnext.products.make_similar_products = function(wrapper) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
wrapper.similar.run();
|
wrapper.similar.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,8 +1,3 @@
|
|||||||
{% extends "product/product_category.js" %}
|
|
||||||
|
|
||||||
{% block javascript %}
|
|
||||||
{{ super() }}
|
|
||||||
|
|
||||||
// ERPNext - web based ERP (http://erpnext.com)
|
// ERPNext - web based ERP (http://erpnext.com)
|
||||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
//
|
//
|
||||||
@ -20,7 +15,8 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// js inside blog page
|
// js inside blog page
|
||||||
wn.provide('erpnext.products');
|
|
||||||
|
{% include "js/product_category.js" %}
|
||||||
|
|
||||||
wn.pages['{{ name }}'].onload = function(wrapper) {
|
wn.pages['{{ name }}'].onload = function(wrapper) {
|
||||||
erpnext.products.wrapper = wrapper;
|
erpnext.products.wrapper = wrapper;
|
||||||
@ -107,6 +103,4 @@ erpnext.products.get_group = function() {
|
|||||||
erpnext.products.cur_group = null;
|
erpnext.products.cur_group = null;
|
||||||
}
|
}
|
||||||
return {grp:grp, label:label};
|
return {grp:grp, label:label};
|
||||||
}
|
}
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
@ -1,4 +1,4 @@
|
|||||||
{% extends "outer.html" %}
|
{% extends "html/outer.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="content">
|
<div class="content">
|
||||||
@ -1,17 +1,15 @@
|
|||||||
{% extends "blog/blog_list.js" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
{% block title %}Blog{% endblock %}
|
{% block javascript %}
|
||||||
|
{% include "js/blog.js" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block css %}
|
{% block css %}
|
||||||
<style>
|
{% include "css/blog.css" %}
|
||||||
h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
|
|
||||||
h2 > a:hover, h2 > a:focus {
|
|
||||||
text-decoration: none;
|
|
||||||
color: inherit;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block title %}Blog{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="layout-wrapper layout-wrapper-background">
|
<div class="layout-wrapper layout-wrapper-background">
|
||||||
<div class="web-content" id="content-blog">
|
<div class="web-content" id="content-blog">
|
||||||
1
erpnext/website/templates/pages/index.html
Normal file
1
erpnext/website/templates/pages/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
{% extends "html/web_page.html" %}
|
||||||
@ -1,4 +1,12 @@
|
|||||||
{% extends "login/login.js" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{% include "js/login.js" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{% include "css/login.css" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
Login Page
|
Login Page
|
||||||
@ -41,17 +49,4 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
<style>
|
|
||||||
#login_wrapper {
|
|
||||||
width: 300px !important;
|
|
||||||
margin: 20px auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
.login-banner {
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -1,4 +1,12 @@
|
|||||||
{% extends "product/product_list.js" %}
|
{% extends "html/page.html" %}
|
||||||
|
|
||||||
|
{% block javascript %}
|
||||||
|
{% include "js/products.js" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block css %}
|
||||||
|
{% include "css/products.css" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block title %}
|
{% block title %}
|
||||||
Products
|
Products
|
||||||
@ -26,18 +34,4 @@
|
|||||||
<div style="clear: both"></div>
|
<div style="clear: both"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block css %}
|
|
||||||
<style>
|
|
||||||
.img-area {
|
|
||||||
float:left;
|
|
||||||
width: 115px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.product-list-description {
|
|
||||||
float:left;
|
|
||||||
width: 400px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -17,6 +17,12 @@
|
|||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.model.doc import Document
|
from webnotes.model.doc import Document
|
||||||
|
|
||||||
|
def scrub_page_name(page_name):
|
||||||
|
if page_name.endswith('.html'):
|
||||||
|
page_name = page_name[:-5]
|
||||||
|
|
||||||
|
return page_name
|
||||||
|
|
||||||
def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
|
def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
|
||||||
"""make template"""
|
"""make template"""
|
||||||
import os, jinja2
|
import os, jinja2
|
||||||
@ -35,82 +41,3 @@ def page_name(title):
|
|||||||
name = title.lower()
|
name = title.lower()
|
||||||
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
|
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
|
||||||
return '-'.join(name.split()[:4])
|
return '-'.join(name.split()[:4])
|
||||||
|
|
||||||
def get_header(page_name):
|
|
||||||
"""get page header"""
|
|
||||||
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
from jinja2 import Template
|
|
||||||
import webnotes.utils
|
|
||||||
|
|
||||||
def get_item(l, label):
|
|
||||||
for i in l:
|
|
||||||
if i['label']==label:
|
|
||||||
return i
|
|
||||||
|
|
||||||
top_bar_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)
|
|
||||||
|
|
||||||
# build child items
|
|
||||||
for t in top_bar_items:
|
|
||||||
if t.get('parent_label'):
|
|
||||||
pi = get_item(top_bar_items, t['parent_label'])
|
|
||||||
if 'child_items' not in pi:
|
|
||||||
pi['child_items'] = []
|
|
||||||
pi['child_items'].append(t)
|
|
||||||
|
|
||||||
website_settings = Document('Website Settings', 'Website Settings')
|
|
||||||
|
|
||||||
return Template("""<div class="navbar navbar-fixed-top">
|
|
||||||
<div class="navbar-inner">
|
|
||||||
<div class="container">
|
|
||||||
<a class="brand" href="index.html">{{ brand }}</a>
|
|
||||||
<ul class="nav">
|
|
||||||
{% for page in top_bar_items %}
|
|
||||||
{% if not page.parent_label %}
|
|
||||||
<li data-label="{{ page.label }}">
|
|
||||||
<a href="{{ page.url }}" {{ page.target }}>
|
|
||||||
{{ page.label }}
|
|
||||||
{% if page.child_items %}
|
|
||||||
<ul class="dropdown-menu">
|
|
||||||
{% for child in page.child_items %}
|
|
||||||
<li data-label="{{ child.label }}">
|
|
||||||
<a href="{{ child.url }}" {{ child.target }}>
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% endif %}
|
|
||||||
</a></li>
|
|
||||||
{% endif %}
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
<img src="images/lib/ui/spinner.gif" id="spinner"/>
|
|
||||||
<ul class="nav pull-right">
|
|
||||||
<li id="login-topbar-item"><a href="login-page.html">Login</a></li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>""").render(top_bar_items = top_bar_items,
|
|
||||||
brand=website_settings.brand_html or webnotes.utils.get_defaults('company') or 'ERPNext')
|
|
||||||
|
|
||||||
def get_footer(page_name):
|
|
||||||
"""get page footer"""
|
|
||||||
|
|
||||||
from webnotes.model.doc import Document
|
|
||||||
from jinja2 import Template
|
|
||||||
|
|
||||||
website_settings = Document('Website Settings', 'Website Settings')
|
|
||||||
|
|
||||||
website_settings.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)
|
|
||||||
|
|
||||||
return Template("""<div class="web-footer">
|
|
||||||
<div class="web-footer-menu"><ul>
|
|
||||||
{% for item in footer_items %}
|
|
||||||
<li><a href="{{ item.url }}" {{ item.target }}
|
|
||||||
data-label="{{ item.label }}">{{ item.label }}</a></li>
|
|
||||||
{% endfor %}
|
|
||||||
</ul></div>
|
|
||||||
<div class="web-footer-copyright">© {{ copyright }}
|
|
||||||
</div>""").render(website_settings.fields)
|
|
||||||
@ -14,108 +14,136 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
page_exception_list = ['404', 'blog', 'products', 'login-page']
|
# html generation functions
|
||||||
|
|
||||||
# used by web.py
|
template_map = {
|
||||||
def load_from_web_cache(page_name, comments, template):
|
'Web Page': 'html/web_page.html',
|
||||||
"""
|
'Blog': 'html/blog_page.html',
|
||||||
* search for page in cache
|
'Item': 'html/product_page.html',
|
||||||
* if html exists, return
|
}
|
||||||
* if not, build html, store it in cache, return
|
|
||||||
"""
|
def get_html(page_name, comments=''):
|
||||||
import webnotes
|
|
||||||
import conf
|
import conf
|
||||||
|
|
||||||
|
html = ''
|
||||||
|
|
||||||
|
# load from cache, if auto cache clear is falsy
|
||||||
|
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
||||||
|
html = load_from_cache(page_name)
|
||||||
|
|
||||||
res = webnotes.conn.sql("""\
|
if not html:
|
||||||
select html, doc_type, doc_name from `tabWeb Cache`
|
html = load_into_cache(page_name)
|
||||||
where name = %s""", page_name)
|
|
||||||
|
|
||||||
# if page doesn't exist, raise exception
|
|
||||||
if not res and page_name not in page_exception_list + ['index']:
|
|
||||||
raise Exception, "Page %s not found" % page_name
|
|
||||||
|
|
||||||
html, doc_type, doc_name = res and res[0] or (None, None, None)
|
|
||||||
auto_cache_clear = hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0
|
|
||||||
if not html or auto_cache_clear:
|
|
||||||
comments += "\n\npage load status: fresh"
|
comments += "\n\npage load status: fresh"
|
||||||
html = load_into_web_cache(page_name, template, doc_type, doc_name)
|
|
||||||
else:
|
# insert comments
|
||||||
comments += "\n\npage load status: cached"
|
import webnotes.utils
|
||||||
|
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
|
||||||
from webnotes.utils import cstr
|
|
||||||
html += """\n<!-- %s -->""" % cstr(comments)
|
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def load_into_web_cache(page_name, template, doc_type, doc_name):
|
def load_from_cache(page_name):
|
||||||
"""build html and store it in web cache"""
|
|
||||||
import webnotes
|
import webnotes
|
||||||
|
|
||||||
|
result = search_cache(page_name)
|
||||||
|
|
||||||
args = prepare_args(page_name, doc_type, doc_name)
|
if not result:
|
||||||
|
if page_name in get_predefined_pages():
|
||||||
|
# if a predefined page doesn't exist, load it into cache
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
# if page doesn't exist, raise exception
|
||||||
|
raise Exception, "Page %s not found" % page_name
|
||||||
|
|
||||||
|
return result[0][0]
|
||||||
|
|
||||||
|
def load_into_cache(page_name):
|
||||||
|
args = prepare_args(page_name)
|
||||||
|
|
||||||
# decide template and update args
|
html = build_html(args)
|
||||||
if doc_type == 'Web Page':
|
|
||||||
template = 'web_page.html'
|
|
||||||
else:
|
|
||||||
args.update({ 'insert_code': 1 })
|
|
||||||
if doc_type == 'Blog':
|
|
||||||
template = 'blog/blog.html'
|
|
||||||
elif doc_type == 'Item':
|
|
||||||
template = 'product/product.html'
|
|
||||||
elif page_name == 'blog':
|
|
||||||
template = 'blog/blog_list.html'
|
|
||||||
elif page_name == 'products':
|
|
||||||
template = 'product/product_list.html'
|
|
||||||
elif page_name == 'login-page':
|
|
||||||
template = 'login/login.html'
|
|
||||||
|
|
||||||
html = build_html(args, template)
|
# create cache entry for predefined pages, if not exists
|
||||||
|
if page_name in get_predefined_pages():
|
||||||
|
create_cache(page_name)
|
||||||
|
|
||||||
# save html in web cache
|
import webnotes
|
||||||
webnotes.conn.begin()
|
webnotes.conn.begin()
|
||||||
if page_name in page_exception_list + ['index']:
|
|
||||||
clear_web_cache(doc_type, doc_name, page_name)
|
|
||||||
webnotes.conn.set_value('Web Cache', page_name, 'html', html)
|
webnotes.conn.set_value('Web Cache', page_name, 'html', html)
|
||||||
webnotes.conn.commit()
|
webnotes.conn.commit()
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
def prepare_args(page_name, doc_type, doc_name, with_outer_env=1):
|
|
||||||
if page_name == 'index':
|
|
||||||
page_name, doc_type, doc_name = get_index_page()
|
|
||||||
|
|
||||||
if page_name in page_exception_list:
|
def get_predefined_pages():
|
||||||
|
"""
|
||||||
|
gets a list of predefined pages
|
||||||
|
they do not exist in `tabWeb Page`
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import conf
|
||||||
|
import website.utils
|
||||||
|
|
||||||
|
pages_path = os.path.join(conf.modules_path, 'website', 'templates', 'pages')
|
||||||
|
|
||||||
|
page_list = []
|
||||||
|
|
||||||
|
for page in os.listdir(pages_path):
|
||||||
|
page_list.append(website.utils.scrub_page_name(page))
|
||||||
|
|
||||||
|
return page_list
|
||||||
|
|
||||||
|
def prepare_args(page_name):
|
||||||
|
if page_name == 'index':
|
||||||
|
page_name = get_home_page()
|
||||||
|
|
||||||
|
if page_name in get_predefined_pages():
|
||||||
args = {
|
args = {
|
||||||
|
'template': 'pages/%s.html' % page_name,
|
||||||
'name': page_name,
|
'name': page_name,
|
||||||
}
|
}
|
||||||
else:
|
else:
|
||||||
from webnotes.model.code import get_obj
|
args = get_doc_fields(page_name)
|
||||||
obj = get_obj(doc_type, doc_name)
|
|
||||||
if hasattr(obj, 'prepare_template_args'):
|
args.update(get_outer_env())
|
||||||
obj.prepare_template_args()
|
|
||||||
args = obj.doc.fields
|
return args
|
||||||
|
|
||||||
|
def get_home_page():
|
||||||
|
import webnotes
|
||||||
|
doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
|
||||||
|
if doc_name:
|
||||||
|
page_name = webnotes.conn.get_value('Web Page', doc_name, 'page_name')
|
||||||
|
else:
|
||||||
|
page_name = 'login'
|
||||||
|
|
||||||
outer_env_dict = with_outer_env and get_outer_env() or {}
|
return page_name
|
||||||
args.update(outer_env_dict)
|
|
||||||
|
def get_doc_fields(page_name):
|
||||||
|
import webnotes
|
||||||
|
doc_type, doc_name = webnotes.conn.get_value('Web Cache', page_name, ['doc_type', 'doc_name'])
|
||||||
|
|
||||||
|
import webnotes.model.code
|
||||||
|
obj = webnotes.model.code.get_obj(doc_type, doc_name)
|
||||||
|
|
||||||
|
if hasattr(obj, 'prepare_template_args'):
|
||||||
|
obj.prepare_template_args()
|
||||||
|
|
||||||
|
args = obj.doc.fields
|
||||||
|
args['template'] = template_map[doc_type]
|
||||||
|
|
||||||
return args
|
return args
|
||||||
|
|
||||||
def build_html(args, template):
|
|
||||||
"""build html using jinja2 templates"""
|
|
||||||
from jinja2 import Environment, FileSystemLoader
|
|
||||||
jenv = Environment(loader = FileSystemLoader('../erpnext/website/templates'))
|
|
||||||
html = jenv.get_template(template).render(args)
|
|
||||||
return html
|
|
||||||
|
|
||||||
def get_outer_env():
|
def get_outer_env():
|
||||||
"""env dict for outer template"""
|
"""
|
||||||
|
env dict for outer template
|
||||||
|
"""
|
||||||
import webnotes
|
import webnotes
|
||||||
return {
|
return {
|
||||||
'top_bar_items': webnotes.conn.sql("""select * from `tabTop Bar Item`
|
'top_bar_items': webnotes.conn.sql("""\
|
||||||
|
select * from `tabTop Bar Item`
|
||||||
where parent='Website Settings' and parentfield='top_bar_items'
|
where parent='Website Settings' and parentfield='top_bar_items'
|
||||||
order by idx asc""", as_dict=1),
|
order by idx asc""", as_dict=1),
|
||||||
|
|
||||||
'footer_items': webnotes.conn.sql("""select * from `tabTop Bar Item`
|
'footer_items': webnotes.conn.sql("""\
|
||||||
|
select * from `tabTop Bar Item`
|
||||||
where parent='Website Settings' and parentfield='footer_items'
|
where parent='Website Settings' and parentfield='footer_items'
|
||||||
order by idx asc""", as_dict=1),
|
order by idx asc""", as_dict=1),
|
||||||
|
|
||||||
@ -124,44 +152,62 @@ def get_outer_env():
|
|||||||
'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon')
|
'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon')
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_index_page():
|
def build_html(args):
|
||||||
import webnotes
|
"""
|
||||||
doc_type = 'Web Page'
|
build html using jinja2 templates
|
||||||
doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
|
"""
|
||||||
page_name = webnotes.conn.get_value(doc_type, doc_name, 'page_name')
|
import os
|
||||||
if not page_name:
|
import conf
|
||||||
page_name = 'login-page'
|
templates_path = os.path.join(conf.modules_path, 'website', 'templates')
|
||||||
return page_name, doc_type, doc_name
|
|
||||||
|
from jinja2 import Environment, FileSystemLoader
|
||||||
|
jenv = Environment(loader = FileSystemLoader(templates_path))
|
||||||
|
html = jenv.get_template(args['template']).render(args)
|
||||||
|
return html
|
||||||
|
|
||||||
# cache management
|
# cache management
|
||||||
def clear_web_cache(doc_type, doc_name, page_name):
|
def search_cache(page_name):
|
||||||
"""
|
|
||||||
* check if a record corresponding to (type, name) exists
|
|
||||||
* if exists, just clear html column
|
|
||||||
* if does not exist, create a record for (type, name)
|
|
||||||
* if a record like (some other type, name) exists, raise exception that the page name is not unique
|
|
||||||
"""
|
|
||||||
import webnotes
|
import webnotes
|
||||||
res = webnotes.conn.get_value('Web Cache', page_name, ['doc_type', 'name'])
|
return webnotes.conn.sql("""\
|
||||||
if not res:
|
select html, doc_type, doc_name
|
||||||
import webnotes.model.doc
|
from `tabWeb Cache`
|
||||||
d = webnotes.model.doc.Document('Web Cache')
|
where name = %s""", page_name)
|
||||||
d.name = page_name
|
|
||||||
d.doc_type = doc_type
|
def create_cache(page_name, doc_type=None, doc_name=None):
|
||||||
d.doc_name = doc_name
|
# check if a record already exists
|
||||||
d.html = None
|
result = search_cache(page_name)
|
||||||
d.save()
|
if result: return
|
||||||
elif not doc_type or res[0] == doc_type:
|
|
||||||
webnotes.conn.set_value('Web Cache', page_name, 'html', None)
|
# create a Web Cache record
|
||||||
|
import webnotes.model.doc
|
||||||
|
d = webnotes.model.doc.Document('Web Cache')
|
||||||
|
d.name = page_name
|
||||||
|
d.doc_type = doc_type
|
||||||
|
d.doc_name = doc_name
|
||||||
|
d.html = None
|
||||||
|
d.save()
|
||||||
|
|
||||||
|
def clear_cache(page_name, doc_type=None, doc_name=None):
|
||||||
|
"""
|
||||||
|
* if no page name, clear whole cache
|
||||||
|
* if page_name, doc_type and doc_name match, clear cache's copy
|
||||||
|
* else, raise exception that such a page already exists
|
||||||
|
"""
|
||||||
|
if not page_name:
|
||||||
|
webnotes.conn.sql("""update `tabWeb Cache` set html = ''""")
|
||||||
|
return
|
||||||
|
|
||||||
|
result = search_cache(page_name)
|
||||||
|
|
||||||
|
import webnotes
|
||||||
|
if not doc_type or (result and result[0][1] == doc_type and result[0][2] == doc_name):
|
||||||
|
webnotes.conn.set_value('Web Cache', page_name, 'html', '')
|
||||||
else:
|
else:
|
||||||
webnotes.msgprint("""Page with name "%s" already exists as a %s.
|
webnotes.msgprint("""Page with name "%s" already exists as a %s.
|
||||||
Please save it with another name.""" % (page_name, res[0]), raise_exception=1)
|
Please save it with another name.""" % (page_name, result[0][1]),
|
||||||
|
raise_exception=1)
|
||||||
def clear_all_web_cache():
|
|
||||||
import webnotes
|
def delete_cache(page_name):
|
||||||
webnotes.conn.sql("update `tabWeb Cache` set html = NULL")
|
|
||||||
|
|
||||||
def delete_web_cache(page_name):
|
|
||||||
"""
|
"""
|
||||||
delete entry of page_name from Web Cache
|
delete entry of page_name from Web Cache
|
||||||
used when:
|
used when:
|
||||||
@ -169,33 +215,29 @@ def delete_web_cache(page_name):
|
|||||||
* blog is un-published
|
* blog is un-published
|
||||||
"""
|
"""
|
||||||
import webnotes
|
import webnotes
|
||||||
webnotes.conn.sql("""\
|
webnotes.conn.sql("""delete from `tabWeb Cache` where name=%s""", page_name)
|
||||||
delete from `tabWeb Cache`
|
|
||||||
where name=%s""", page_name)
|
def refresh_cache():
|
||||||
|
"""delete and re-create web cache entries"""
|
||||||
def rebuild_web_cache():
|
|
||||||
"""build web cache entries"""
|
|
||||||
import webnotes
|
import webnotes
|
||||||
from webnotes.model.doclist import DocList
|
|
||||||
save_list = [
|
|
||||||
{
|
|
||||||
'doctype': 'Web Page',
|
|
||||||
'query': """select name from `tabWeb Page` where docstatus=0"""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'doctype': 'Blog',
|
|
||||||
'query': """\
|
|
||||||
select name from `tabBlog`
|
|
||||||
where docstatus = 0 and ifnull(published, 0) = 1"""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
'doctype': 'Item',
|
|
||||||
'query': """\
|
|
||||||
select name from `tabItem`
|
|
||||||
where docstatus = 0 and ifnull(show_in_website, 0) = 1"""
|
|
||||||
}
|
|
||||||
]
|
|
||||||
|
|
||||||
for s in save_list:
|
webnotes.conn.sql("delete from `tabWeb Cache`")
|
||||||
for p in webnotes.conn.sql(s['query'], as_dict=1):
|
|
||||||
DocList(s['doctype'], p['name']).save()
|
query_map = {
|
||||||
|
'Web Page': """select page_name, name from `tabWeb Page` where docstatus=0""",
|
||||||
|
'Blog': """\
|
||||||
|
select page_name, name from `tabBlog`
|
||||||
|
where docstatus = 0 and ifnull(published, 0) = 1""",
|
||||||
|
'Item': """\
|
||||||
|
select page_name, name from `tabItem`
|
||||||
|
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
|
||||||
|
}
|
||||||
|
|
||||||
|
for dt in query_map:
|
||||||
|
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||||
|
create_cache(result['page_name'], dt, result['name'])
|
||||||
|
clear_cache(result['page_name'], dt, result['name'])
|
||||||
|
|
||||||
|
for page_name in get_predefined_pages():
|
||||||
|
create_cache(page_name, None, None)
|
||||||
|
clear_cache(page_name, None, None)
|
||||||
@ -64,11 +64,12 @@ class Page(object):
|
|||||||
self.old_page_name != self.doc.page_name:
|
self.old_page_name != self.doc.page_name:
|
||||||
self.delete_web_cache(self.old_page_name)
|
self.delete_web_cache(self.old_page_name)
|
||||||
|
|
||||||
website.web_cache.clear_web_cache(self.doctype, self.doc.name, self.doc.page_name)
|
website.web_cache.create_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||||
|
website.web_cache.clear_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||||
|
|
||||||
def delete_web_cache(self, page_name):
|
def delete_web_cache(self, page_name):
|
||||||
"""delete entry of page name from Web Cache"""
|
"""delete entry of page name from Web Cache"""
|
||||||
website.web_cache.delete_web_cache(page_name)
|
website.web_cache.delete_cache(page_name)
|
||||||
|
|
||||||
def markdown_to_html(self, fields_list):
|
def markdown_to_html(self, fields_list):
|
||||||
"""convert fields from markdown to html"""
|
"""convert fields from markdown to html"""
|
||||||
|
|||||||
@ -27,8 +27,12 @@ sys.path.append('../lib/py')
|
|||||||
import webnotes
|
import webnotes
|
||||||
import webnotes.auth
|
import webnotes.auth
|
||||||
|
|
||||||
|
import conf
|
||||||
|
sys.path.append(conf.modules_path)
|
||||||
|
|
||||||
if __name__=='__main__':
|
if __name__=='__main__':
|
||||||
webnotes.http_request = webnotes.auth.HTTPRequest()
|
# webnotes.http_request = webnotes.auth.HTTPRequest()
|
||||||
|
webnotes.connect()
|
||||||
from webnotes.cms import feed
|
from webnotes.cms import feed
|
||||||
try:
|
try:
|
||||||
print 'Content-Type: text/xml'
|
print 'Content-Type: text/xml'
|
||||||
|
|||||||
@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
# ERPNext - web based ERP (http://erpnext.com)
|
||||||
|
# Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return a dynamic page from website templates
|
return a dynamic page from website templates
|
||||||
|
|
||||||
@ -37,34 +53,27 @@ def respond():
|
|||||||
print
|
print
|
||||||
print html.encode('utf-8')
|
print html.encode('utf-8')
|
||||||
|
|
||||||
def scrub_page_name(page_name):
|
|
||||||
if page_name.endswith('.html'):
|
|
||||||
page_name = page_name[:-5]
|
|
||||||
return page_name
|
|
||||||
|
|
||||||
def get_html(page_name):
|
def get_html(page_name):
|
||||||
import webnotes
|
import website.utils
|
||||||
|
page_name = website.utils.scrub_page_name(page_name)
|
||||||
|
|
||||||
|
comments = get_comments(page_name)
|
||||||
|
|
||||||
import website.web_cache
|
import website.web_cache
|
||||||
page_name = scrub_page_name(page_name)
|
html = website.web_cache.get_html(page_name, comments)
|
||||||
|
|
||||||
if page_name == '404':
|
|
||||||
traceback = webnotes.getTraceback()
|
|
||||||
|
|
||||||
# script is used to display traceback in error console
|
|
||||||
args = {
|
|
||||||
'comments': """error: %s""" % traceback,
|
|
||||||
'template': '404.html',
|
|
||||||
}
|
|
||||||
else:
|
|
||||||
args = {
|
|
||||||
'comments': """page: %s""" % page_name,
|
|
||||||
'template': 'page.html',
|
|
||||||
}
|
|
||||||
|
|
||||||
html = website.web_cache.load_from_web_cache(page_name, **args)
|
|
||||||
|
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
def get_comments(page_name):
|
||||||
|
import webnotes
|
||||||
|
|
||||||
|
if page_name == '404':
|
||||||
|
comments = """error: %s""" % webnotes.getTraceback()
|
||||||
|
else:
|
||||||
|
comments = """page: %s""" % page_name
|
||||||
|
|
||||||
|
return comments
|
||||||
|
|
||||||
if __name__=="__main__":
|
if __name__=="__main__":
|
||||||
init()
|
init()
|
||||||
respond()
|
respond()
|
||||||
Loading…
x
Reference in New Issue
Block a user