Merge branch 'master' of github.com:webnotes/erpnext into cms2
diff --git a/build.json b/build.json
index 7b1dfe6..6efbbc3 100644
--- a/build.json
+++ b/build.json
@@ -23,7 +23,4 @@
"public/js/complete_setup.js": [
"erpnext/startup/js/complete_setup.js",
],
- "public/js/product_category.js": [
- "erpnext/website/js/product_category.js",
- ],
}
\ No newline at end of file
diff --git a/erpnext/patches/june_2012/cms2.py b/erpnext/patches/june_2012/cms2.py
new file mode 100644
index 0000000..fe4774e
--- /dev/null
+++ b/erpnext/patches/june_2012/cms2.py
@@ -0,0 +1,59 @@
+def execute():
+ import webnotes
+ import webnotes.model.sync
+
+ # sync web page, blog doctype
+ webnotes.model.sync.sync('website', 'web_page')
+ webnotes.model.sync.sync('website', 'blog')
+
+ cleanup()
+
+ save_pages()
+
+def cleanup():
+ import webnotes
+
+ # delete pages from `tabPage` of module Website or of type Webpage
+ webnotes.conn.sql("""\
+ delete from `tabPage`
+ where module='Website' and ifnull(web_page, 'No') = 'Yes'""")
+
+ # change show_in_website value in item table to 0 or 1
+ webnotes.conn.sql("""\
+ update `tabItem`
+ set show_in_website = if(show_in_website = 'Yes', 1, 0)
+ where show_in_website is not null""")
+
+ # move comments from comment_doctype Page to Blog
+ webnotes.conn.sql("""\
+ update `tabComment` comm, `tabBlog` blog
+ set comm.comment_doctype = 'Blog', comm.comment_docname = blog.name
+ where comm.comment_docname = blog.page_name""")
+
+
+def save_pages():
+ """save all web pages, blogs to create content"""
+ 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, 'No') = 'Yes'"""
+ }
+ ]
+
+ for s in save_list:
+ for p in webnotes.conn.sql(s['query'], as_dict=1):
+ DocList(s['doctype'], p['name']).save()
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/item.js b/erpnext/stock/doctype/item/item.js
index 65698c1..572a790 100644
--- a/erpnext/stock/doctype/item/item.js
+++ b/erpnext/stock/doctype/item/item.js
@@ -29,8 +29,23 @@
}
$c_obj(make_doclist(doc.doctype, doc.name),'check_if_sle_exists','',callback);
}
+
+ cur_frm.cscript.hide_website_fields(doc);
}
+cur_frm.cscript.hide_website_fields = function(doc) {
+ var website_fields_list = ['page_name', 'website_image', 'web_short_description',
+ 'web_long_description']
+ if (cint(doc.show_in_website)) {
+ unhide_field(website_fields_list);
+ } else {
+ hide_field(website_fields_list);
+ }
+}
+
+cur_frm.cscript.show_in_website = function(doc, dt, dn) {
+ cur_frm.cscript.hide_website_fields(doc);
+}
cur_frm.fields_dict['default_bom'].get_query = function(doc) {
//var d = locals[this.doctype][this.docname];
diff --git a/erpnext/stock/doctype/item/item.py b/erpnext/stock/doctype/item/item.py
index 0f6cc4c..c8d6392 100644
--- a/erpnext/stock/doctype/item/item.py
+++ b/erpnext/stock/doctype/item/item.py
@@ -46,6 +46,8 @@
return ret
def on_update(self):
+ self.update_page_name()
+
bin = sql("select stock_uom from `tabBin` where item_code = '%s' " % self.doc.item_code)
if bin and cstr(bin[0][0]) != cstr(self.doc.stock_uom):
msgprint("Please Update Stock UOM with the help of Stock UOM Replace Utility.")
@@ -78,9 +80,14 @@
child.conversion_factor = 1
child.save()
+ self.clear_web_cache()
+
# On delete 1. Delete BIN (if none of the corrosponding transactions present, it gets deleted. if present, rolled back due to exception)
def on_trash(self):
sql("delete from tabBin where item_code='%s'"%(self.doc.item_code))
+
+ import website.web_cache
+ website.web_cache.delete_web_cache(self.doc.page_name)
# Check whether Ref Rate is not entered twice for same Price List and Currency
def check_ref_rate_detail(self):
@@ -162,9 +169,9 @@
if self.doc.has_serial_no == 'Yes' and self.doc.is_stock_item == 'No':
msgprint("'Has Serial No' can not be 'Yes' for non-stock item", raise_exception=1)
- # make product page
- self.make_page()
-
+ if self.doc.name:
+ self.old_page_name = webnotes.conn.get_value('Item', self.doc.name, 'page_name')
+
def check_non_asset_warehouse(self):
if self.doc.is_asset_item == "Yes":
existing_qty = sql("select t1.warehouse, t1.actual_qty from tabBin t1, tabWarehouse t2 where t1.item_code=%s and (t2.warehouse_type!='Fixed Asset' or t2.warehouse_type is null) and t1.warehouse=t2.name and t1.actual_qty > 0", self.doc.name)
@@ -217,35 +224,34 @@
def on_rename(self,newdn,olddn):
sql("update tabItem set item_code = %s where name = %s", (newdn, olddn))
- def make_page(self):
- if self.doc.show_in_website=='Yes':
+ def clear_web_cache(self):
+ import website.web_cache
+
+ if hasattr(self, 'old_page_name') and self.old_page_name and \
+ self.doc.page_name != self.old_page_name:
+ website.web_cache.delete_web_cache(self.old_page_name)
+
+ if self.doc.show_in_website:
+ website.web_cache.clear_web_cache(self.doc.doctype, self.doc.name, self.doc.page_name)
+ else:
+ website.web_cache.delete_web_cache(self.doc.page_name)
+
+ def update_page_name(self):
+ import website.utils
+
+ # if same name, do not repeat twice
+ if self.doc.name == self.doc.item_name:
+ page_name = self.doc.name
+ else:
+ page_name = self.doc.name + " " + self.doc.item_name
- import website.utils
+ self.doc.page_name = website.utils.page_name(page_name)
- if self.doc.page_name:
- import webnotes.model
- webnotes.model.delete_doc('Page', self.doc.page_name)
-
- p = website.utils.add_page("Product " + self.doc.item_name)
- self.doc.page_name = p.name
-
- from jinja2 import Template
- import markdown2
- import os
-
-
- self.doc.long_description_html = markdown2.markdown(self.doc.description or '')
-
- with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
- p.content = Template(f.read()).render(doc=self.doc)
-
- with open(os.path.join(os.path.dirname(__file__), 'product_page.js'), 'r') as f:
- p.script = Template(f.read()).render(doc=self.doc)
-
- p.save()
-
- website.utils.add_guest_access_to_page(p.name)
-
- del self.doc.fields['long_description_html']
-
-
\ No newline at end of file
+ webnotes.conn.set_value('Item', self.doc.name, 'page_name', self.doc.page_name)
+
+ # no need to check for uniqueness, as name is unique
+
+ def get_html(self):
+ import markdown2
+ self.doc.web_description_html = markdown2.markdown(self.doc.description or '',
+ extras=["wiki-tables"])
diff --git a/erpnext/stock/doctype/item/item.txt b/erpnext/stock/doctype/item/item.txt
index 8a079b8..06806ba 100644
--- a/erpnext/stock/doctype/item/item.txt
+++ b/erpnext/stock/doctype/item/item.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-04-30 18:33:53',
+ 'creation': '2012-06-08 12:54:51',
'docstatus': 0,
- 'modified': '2012-06-07 16:16:24',
+ 'modified': '2012-07-04 11:10:29',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -59,73 +59,6 @@
# DocPerm
{
- 'amend': 0,
- 'cancel': 0,
- 'create': 0,
- 'doctype': u'DocPerm',
- 'permlevel': 1,
- 'role': u'Material Manager',
- 'submit': 0,
- 'write': 0
- },
-
- # DocPerm
- {
- 'amend': 0,
- 'cancel': 0,
- 'create': 0,
- 'doctype': u'DocPerm',
- 'permlevel': 0,
- 'role': u'Material Manager',
- 'submit': 0,
- 'write': 0
- },
-
- # DocPerm
- {
- 'amend': 0,
- 'cancel': 0,
- 'create': 0,
- 'doctype': u'DocPerm',
- 'permlevel': 1,
- 'role': u'Material User',
- 'submit': 0,
- 'write': 0
- },
-
- # DocPerm
- {
- 'amend': 0,
- 'cancel': 0,
- 'create': 0,
- 'doctype': u'DocPerm',
- 'permlevel': 0,
- 'role': u'Material User',
- 'submit': 0,
- 'write': 0
- },
-
- # DocPerm
- {
- 'cancel': 1,
- 'create': 1,
- 'doctype': u'DocPerm',
- 'permlevel': 0,
- 'role': u'Material Master Manager',
- 'write': 1
- },
-
- # DocPerm
- {
- 'create': 0,
- 'doctype': u'DocPerm',
- 'permlevel': 1,
- 'role': u'Material Master Manager',
- 'write': 0
- },
-
- # DocPerm
- {
'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
@@ -136,11 +69,78 @@
# DocPerm
{
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'permlevel': 1,
+ 'role': u'Material Master Manager',
+ 'write': 0
+ },
+
+ # DocPerm
+ {
+ 'cancel': 1,
+ 'create': 1,
+ 'doctype': u'DocPerm',
+ 'permlevel': 0,
+ 'role': u'Material Master Manager',
+ 'write': 1
+ },
+
+ # DocPerm
+ {
'doctype': u'DocPerm',
'permlevel': 1,
'role': u'System Manager'
},
+ # DocPerm
+ {
+ 'amend': 0,
+ 'cancel': 0,
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'permlevel': 1,
+ 'role': u'Material Manager',
+ 'submit': 0,
+ 'write': 0
+ },
+
+ # DocPerm
+ {
+ 'amend': 0,
+ 'cancel': 0,
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'permlevel': 0,
+ 'role': u'Material Manager',
+ 'submit': 0,
+ 'write': 0
+ },
+
+ # DocPerm
+ {
+ 'amend': 0,
+ 'cancel': 0,
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'permlevel': 1,
+ 'role': u'Material User',
+ 'submit': 0,
+ 'write': 0
+ },
+
+ # DocPerm
+ {
+ 'amend': 0,
+ 'cancel': 0,
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'permlevel': 0,
+ 'role': u'Material User',
+ 'submit': 0,
+ 'write': 0
+ },
+
# DocField
{
'doctype': u'DocField',
@@ -734,26 +734,6 @@
# DocField
{
'doctype': u'DocField',
- 'fieldname': u'show_in_website',
- 'fieldtype': u'Select',
- 'label': u'Show in Website',
- 'options': u'No\nYes',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
- 'fieldname': u'website_image',
- 'fieldtype': u'Select',
- 'label': u'website_image',
- 'options': u'attach_files:',
- 'permlevel': 0
- },
-
- # DocField
- {
- 'doctype': u'DocField',
'fieldname': u'max_discount',
'fieldtype': u'Currency',
'label': u'Max Discount (%)',
@@ -796,17 +776,6 @@
# DocField
{
- 'colour': u'White:FFF',
- 'description': u'website page link',
- 'doctype': u'DocField',
- 'fieldname': u'page_name',
- 'fieldtype': u'Data',
- 'label': u'Page Name',
- 'permlevel': 1
- },
-
- # DocField
- {
'doctype': u'DocField',
'fieldname': u'column_break3',
'fieldtype': u'Column Break',
@@ -994,5 +963,63 @@
'no_copy': 1,
'permlevel': 0,
'print_hide': 1
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'website_section',
+ 'fieldtype': u'Section Break',
+ 'label': u'Website',
+ 'permlevel': 0
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'show_in_website',
+ 'fieldtype': u'Check',
+ 'label': u'Show in Website',
+ 'permlevel': 0
+ },
+
+ # DocField
+ {
+ 'colour': u'White:FFF',
+ 'description': u'website page link',
+ 'doctype': u'DocField',
+ 'fieldname': u'page_name',
+ 'fieldtype': u'Data',
+ 'label': u'Page Name',
+ 'permlevel': 1
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'website_image',
+ 'fieldtype': u'Select',
+ 'label': u'Image',
+ 'options': u'attach_files:',
+ 'permlevel': 0
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'web_short_description',
+ 'fieldtype': u'Text',
+ 'label': u'Short Description',
+ 'permlevel': 0
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'web_long_description',
+ 'fieldtype': u'Code',
+ 'label': u'Long Description',
+ 'options': u'Markdown',
+ 'permlevel': 0
}
]
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/product_page.js b/erpnext/stock/doctype/item/product_page.js
deleted file mode 100644
index 926ef69..0000000
--- a/erpnext/stock/doctype/item/product_page.js
+++ /dev/null
@@ -1,63 +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.require('erpnext/website/js/product_category.js');
-
-pscript["onload_{{ doc.page_name }}"] = function(wrapper) {
- wrapper.product_group = "{{ doc.item_group }}";
- wrapper.product_name = "{{ doc.name }}";
- erpnext.make_product_categories(wrapper);
- $(wrapper).find('.product-inquiry').click(function() {
- loadpage('contact', function() {
- $('#content-contact-us [name="contact-message"]').val("Hello,\n\n\
- Please send me more information on {{ doc.title }} (Item Code:{{ doc.item }})\n\n\
- My contact details are:\n\nThank you!\
- ");
- })
- });
-
- // similar products
- wrapper.similar = new wn.ui.Listing({
- parent: $(wrapper).find('.similar-products').get(0),
- hide_refresh: true,
- page_length: 5,
- get_query: function() {
- args = {
- cat: wrapper.product_group,
- name: wrapper.product_name
- };
- return repl('select t1.name, t1.title, t1.thumbnail_image, \
- t1.page_name, t1.short_description \
- from tabProduct t1, tabItem t2 \
- where t1.item = t2.name \
- and ifnull(t1.published,0)=1 \
- and t1.name != "%(name)s" \
- and t2.item_group="%(cat)s" order by t1.modified desc', args)
- },
- render_row: function(parent, data) {
- if(data.short_description.length > 100) {
- data.short_description = data.short_description.substr(0,100) + '...';
- }
- parent.innerHTML = repl('<div style="float:left; width: 60px;">\
- <img src="files/%(thumbnail_image)s" style="width:55px;"></div>\
- <div style="float:left; width: 180px">\
- <b><a href="#!%(page_name)s">%(title)s</a></b>\
- <p>%(short_description)s</p></div>\
- <div style="clear: both; margin-bottom: 15px;"></div>', data);
- }
- });
- wrapper.similar.run();
-}
\ No newline at end of file
diff --git a/erpnext/stock/doctype/item/template.html b/erpnext/stock/doctype/item/template.html
deleted file mode 100644
index 8a2f4a9..0000000
--- a/erpnext/stock/doctype/item/template.html
+++ /dev/null
@@ -1,25 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
- <div class="web-content" id="content-product-{{ doc.name }}">
- <div class="layout-main-section">
- <h1>{{ doc.item_name }}</h1>
- <div style="float: left;">
- <br><br>
- <image src="files/{{ doc.website_image }}" style="width: 300px;
- margin-left: 15px;" />
- <br><br>
- {{ doc.long_description_html }}
- <button class="btn primary product-inquiry"
- data-product="{{ doc.name }}"
- data-description="{{ doc.short_description }}">Send Inquiry</button>
- </div>
- </div>
- <div class="layout-side-section">
- <h4>More Categories</h4>
- <div class="more-categories"></div>
- <br>
- <h4>Similar Products</h4>
- <div class="similar-products"></div>
- </div>
- <div style="clear: both"></div>
- </div>
-</div>
\ No newline at end of file
diff --git a/erpnext/website/doctype/blog/blog.py b/erpnext/website/doctype/blog/blog.py
index 919b830..89a06d4 100644
--- a/erpnext/website/doctype/blog/blog.py
+++ b/erpnext/website/doctype/blog/blog.py
@@ -22,52 +22,37 @@
import webnotes
import website.utils
+import website.web_page
-class DocType():
+class DocType(website.web_page.Page):
def __init__(self, d, dl):
+ super(DocType, self).__init__('Blog')
self.doc, self.doclist = d, dl
+
+ def on_update(self):
+ super(DocType, self).on_update()
+ if not webnotes.utils.cint(self.doc.published):
+ self.delete_web_cache(self.doc.page_name)
+
+ def get_html(self):
+ import webnotes.utils
- def autoname(self):
- """save file by its name"""
- self.doc.name = website.utils.page_name(self.doc.title)
-
- def validate(self):
- """write/update 'Page' with the blog"""
- # we need the name for the templates
- if not self.doc.name:
- self.autoname()
+ # this is for double precaution. usually it wont reach this code if not published
+ if not webnotes.utils.cint(self.doc.published):
+ raise Exception, "This blog has not been published yet!"
- if self.doc.page_name:
- webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
-
- p = website.utils.add_page(self.doc.title)
-
- from jinja2 import Template
- import markdown2
- import os
+ # temp fields
from webnotes.utils import global_date_format, get_fullname
- from webnotes.model.code import get_obj
-
- self.doc.content_html = unicode(markdown2.markdown(self.doc.content or ''))
self.doc.full_name = get_fullname(self.doc.owner)
self.doc.updated = global_date_format(self.doc.modified)
-
- with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
- p.content = Template(f.read()).render(doc=self.doc)
-
- with open(os.path.join(os.path.dirname(__file__), 'blog_page.js'), 'r') as f:
- p.script = Template(f.read()).render(doc=self.doc)
-
- p.web_page = 'Yes'
- p.save()
- get_obj(doc=p).write_cms_page()
-
- website.utils.add_guest_access_to_page(p.name)
- self.doc.page_name = p.name
-
- # cleanup
- for f in ['full_name', 'updated', 'content_html']:
- if f in self.doc.fields:
- del self.doc.fields[f]
-
\ No newline at end of file
+ self.markdown_to_html(['content'])
+
+ comment_list = webnotes.conn.sql("""\
+ select comment, comment_by_fullname, creation
+ from `tabComment` where comment_doctype="Blog"
+ and comment_docname=%s order by creation""", self.doc.name, as_dict=1)
+
+ self.doc.comment_list = comment_list or []
+ for comment in self.doc.comment_list:
+ comment['comment_date'] = webnotes.utils.pretty_date(comment['creation'])
\ No newline at end of file
diff --git a/erpnext/website/doctype/blog/blog.txt b/erpnext/website/doctype/blog/blog.txt
index ad44d13..24187e3 100644
--- a/erpnext/website/doctype/blog/blog.txt
+++ b/erpnext/website/doctype/blog/blog.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-04-02 16:02:43',
+ 'creation': '2012-05-28 19:22:38',
'docstatus': 0,
- 'modified': '2012-04-26 16:58:27',
+ 'modified': '2012-06-22 18:56:16',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -21,7 +21,7 @@
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
- 'version': 5
+ 'version': 1
},
# These values are common for all DocField
@@ -51,6 +51,7 @@
# DocPerm
{
+ 'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
@@ -71,7 +72,14 @@
{
'doctype': u'DocPerm',
'permlevel': 1,
- 'role': u'All'
+ 'role': u'Website Manager'
+ },
+
+ # DocPerm
+ {
+ 'doctype': u'DocPerm',
+ 'permlevel': 1,
+ 'role': u'Blogger'
},
# DocField
@@ -99,6 +107,7 @@
'fieldname': u'content',
'fieldtype': u'Code',
'label': u'Content',
+ 'options': u'Markdown',
'permlevel': 0,
'reqd': 0
},
@@ -106,19 +115,11 @@
# DocField
{
'doctype': u'DocField',
- 'fieldname': u'content_html',
- 'fieldtype': u'Text',
- 'label': u'Content HTML',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
'fieldname': u'page_name',
'fieldtype': u'Data',
+ 'hidden': 1,
'label': u'Page Name',
- 'permlevel': 0
+ 'permlevel': 1
},
# DocField
diff --git a/erpnext/website/doctype/blog/blog_page.js b/erpnext/website/doctype/blog/blog_page.js
deleted file mode 100644
index 4b28392..0000000
--- a/erpnext/website/doctype/blog/blog_page.js
+++ /dev/null
@@ -1,83 +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/>.
-
-// js inside blog page
-
-pscript['onload_{{ doc.name }}'] = function(wrapper) {
- // sidebar
- wrapper.recent_list = new wn.ui.Listing({
- parent: $(wrapper).find('.recent-posts'),
- no_toolbar: true,
- query: 'select name, title, left(content, 100) as content from tabBlog\
- where ifnull(published,0)=1 and name!="{{ doc.name }}" order by creation desc',
- hide_refresh: true,
- render_row: function(parent, data) {
- //console.log(data);
- if(data.content && data.content.length==100) data.content += '...';
- parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
- <div class="comment">%(content)s</div><br>', data);
- },
- page_length: 5,
- });
- wrapper.recent_list.run();
-
- wrapper.comment_list = new wn.ui.Listing({
- parent: $(wrapper).find('.blog-comments').get(0),
- no_toolbar: true,
- query: 'select comment, comment_by_fullname, creation\
- from `tabComment` where comment_doctype="Page"\
- and comment_docname="{{ doc.name }}" order by creation desc',
- no_result_message: 'Be the first one to comment',
- render_row: function(parent, data) {
- data.comment_date = prettyDate(data.creation);
- $(parent).html(repl("<div style='color:#777'>\
- %(comment_by_fullname)s | %(comment_date)s:\
- </div>\
- <p style='margin-left: 20px;'>%(comment)s</p><br>", data))
- },
- hide_refresh: true
- });
- wrapper.comment_list.run();
-
- // add comment
- $(wrapper).find('.layout-main-section').append('<br><button class="btn add-comment">\
- Add Comment</button>');
- $(wrapper).find('button.add-comment').click(function(){
- d = new wn.widgets.Dialog({
- title: 'Add Comment',
- fields: [
- {fieldname:'comment_by_fullname', label:'Your Name', reqd:1, fieldtype:'Data'},
- {fieldname:'comment_by', label:'Email Id', reqd:1, fieldtype:'Data'},
- {fieldname:'comment', label:'Comment', reqd:1, fieldtype:'Text'},
- {fieldname:'post', label:'Post', fieldtype:'Button'}
- ]
- });
- d.fields_dict.post.input.onclick = function() {
- var btn = this;
- var args = d.get_values();
- if(!args) return;
- args.comment_doctype = 'Page';
- args.comment_docname = '{{ doc.name }}';
- $(btn).set_working();
- $c('webnotes.widgets.form.comments.add_comment', args, function(r) {
- $(btn).done_working();
- d.hide();
- wrapper.comment_list.refresh();
- })
- }
- d.show();
- })
-}
\ No newline at end of file
diff --git a/erpnext/website/doctype/blog/template.html b/erpnext/website/doctype/blog/template.html
deleted file mode 100644
index 510f1be..0000000
--- a/erpnext/website/doctype/blog/template.html
+++ /dev/null
@@ -1,24 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
- <div class="web-content" id="blog-{{ doc.name }}">
- <div class="layout-main-section">
- <h2>{{ doc.title }}</h2>
- <div class="help">By {{ doc.full_name }} on {{ doc.updated }}</div>
- <br>
- {{ doc.content_html }}
- <hr><h3>Comments</h3>
- <br>
- <div class="blog-comments"></div>
- </div>
- <div class="layout-side-section">
- <p><a href="blog.html">All Blogs</a></p>
- <h4>Recent Posts</h4>
- <div class="recent-posts" style="min-height: 100px;"></div>
- <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>
\ No newline at end of file
diff --git a/erpnext/website/doctype/web_cache/__init__.py b/erpnext/website/doctype/web_cache/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/website/doctype/web_cache/__init__.py
diff --git a/erpnext/website/doctype/web_cache/web_cache.txt b/erpnext/website/doctype/web_cache/web_cache.txt
new file mode 100644
index 0000000..98a4891
--- /dev/null
+++ b/erpnext/website/doctype/web_cache/web_cache.txt
@@ -0,0 +1,99 @@
+# DocType, Web Cache
+[
+
+ # These values are common in all dictionaries
+ {
+ 'creation': '2012-06-21 12:01:17',
+ 'docstatus': 0,
+ 'modified': '2012-06-21 17:25:52',
+ 'modified_by': u'Administrator',
+ 'owner': u'Administrator'
+ },
+
+ # These values are common for all DocType
+ {
+ 'doctype': 'DocType',
+ 'document_type': u'System',
+ 'module': u'Website',
+ 'name': '__common__',
+ 'version': 1
+ },
+
+ # These values are common for all DocField
+ {
+ 'doctype': u'DocField',
+ 'name': '__common__',
+ 'parent': u'Web Cache',
+ 'parentfield': u'fields',
+ 'parenttype': u'DocType',
+ 'permlevel': 0
+ },
+
+ # These values are common for all DocPerm
+ {
+ 'doctype': u'DocPerm',
+ 'name': '__common__',
+ 'parent': u'Web Cache',
+ 'parentfield': u'permissions',
+ 'parenttype': u'DocType',
+ 'permlevel': 0,
+ 'read': 1,
+ 'write': 1
+ },
+
+ # DocType, Web Cache
+ {
+ 'doctype': 'DocType',
+ 'name': u'Web Cache'
+ },
+
+ # DocPerm
+ {
+ 'create': 0,
+ 'doctype': u'DocPerm',
+ 'role': u'All'
+ },
+
+ # DocPerm
+ {
+ 'create': 1,
+ 'doctype': u'DocPerm',
+ 'role': u'Website Manager'
+ },
+
+ # DocPerm
+ {
+ 'create': 1,
+ 'doctype': u'DocPerm',
+ 'role': u'Blogger'
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'doc_type',
+ 'fieldtype': u'Link',
+ 'in_filter': 1,
+ 'label': u'DocType',
+ 'options': u'DocType',
+ 'reqd': 1
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'doc_name',
+ 'fieldtype': u'Data',
+ 'in_filter': 0,
+ 'label': u'DocName',
+ 'reqd': 1
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
+ 'fieldname': u'html',
+ 'fieldtype': u'Long Text',
+ 'label': u'HTML'
+ }
+]
\ No newline at end of file
diff --git a/erpnext/website/doctype/web_page/template.html b/erpnext/website/doctype/web_page/template.html
deleted file mode 100644
index c6d4b40..0000000
--- a/erpnext/website/doctype/web_page/template.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<div class="layout-wrapper layout-wrapper-background">
- <div class="web-content"
- style="text-align: {{ doc.text_align }};">
-
- {% if doc.layout and doc.layout.startswith('Two column') %}
- <div class="layout-main-section">
- {% else %}
- <div class="layout-main">
- {% endif %}
- {{ doc.main_section_html }}
- {% if doc.next_page_html %}
- {{ doc.next_page_html }}
- {% endif %}
-
- </div>
-
- {% if doc.layout and doc.layout.startswith('Two column') %}
- <div class="layout-side-section">
- {{ doc.side_section_html }}
- {% if doc.see_also %}
- <div class="info-box">
- <h4>See Also</h4>
- {{ doc.see_also }}
- </div>
- {% endif %}
- </div>
- {% endif %}
- <div style="clear: both"></div>
- </div>
-</div>
diff --git a/erpnext/website/doctype/web_page/web_page.py b/erpnext/website/doctype/web_page/web_page.py
index 27ce5c0..37e0cee 100644
--- a/erpnext/website/doctype/web_page/web_page.py
+++ b/erpnext/website/doctype/web_page/web_page.py
@@ -16,82 +16,22 @@
import webnotes
import website.utils
+import website.web_page
-class DocType:
+class DocType(website.web_page.Page):
def __init__(self, d, dl):
+ super(DocType, self).__init__('Web Page')
self.doc, self.doclist = d, dl
-
- def autoname(self):
- """name from title"""
- self.doc.name = website.utils.page_name(self.doc.title)
def on_update(self):
- """make page for this product"""
- from jinja2 import Template
- from webnotes.utils import global_date_format
- from webnotes.model.code import get_obj
- import os
-
- # we need the name for the templates
- if self.doc.name.startswith('New Web Page'):
- self.autoname()
-
- if self.doc.page_name:
- webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
-
- p = website.utils.add_page(self.doc.name)
- self.doc.page_name = p.name
-
- self.doc.updated = global_date_format(self.doc.modified)
- website.utils.markdown(self.doc, ['head_section','main_section', 'side_section'])
-
- with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
- p.content = Template(f.read()).render(doc=self.doc)
-
- p.title = self.doc.title
- p.web_page = 'Yes'
-
- if self.doc.insert_code:
- p.script = self.doc.javascript
-
- if self.doc.insert_style:
- p.style = self.doc.css
-
- p.save()
- get_obj(doc=p).write_cms_page()
-
- website.utils.add_guest_access_to_page(p.name)
- self.cleanup_temp()
-
- self.doc.save()
-
+ super(DocType, self).on_update()
self.if_home_clear_cache()
-
- def add_page_links(self):
- """add links for next_page and see_also"""
- if self.doc.next_page:
- self.doc.next_page_html = """<div class="info-box round" style="text-align: right">
- <b>Next:</b>
- <a href="#!%(name)s">%(title)s</a></div>""" % {"name":self.doc.next_page, \
- "title": webnotes.conn.get_value("Page", self.doc.next_page, "title")}
- self.doc.see_also = ''
- for d in self.doclist:
- if d.doctype=='Related Page':
- tmp = {"page":d.page, "title":webnotes.conn.get_value('Page', d.page, 'title')}
- self.doc.see_also += """<div><a href="#!%(page)s">%(title)s</a></div>""" % tmp
-
- def cleanup_temp(self):
- """cleanup temp fields"""
- fl = ['main_section_html', 'side_section_html', 'see_also', \
- 'next_page_html', 'head_section_html', 'updated']
- for f in fl:
- if f in self.doc.fields:
- del self.doc.fields[f]
-
def if_home_clear_cache(self):
"""if home page, clear cache"""
if webnotes.conn.get_value("Website Settings", None, "home_page")==self.doc.name:
from webnotes.session_cache import clear_cache
- clear_cache('Guest')
-
\ No newline at end of file
+ clear_cache('Guest')
+
+ def get_html(self):
+ self.markdown_to_html(['head_section','main_section', 'side_section'])
\ No newline at end of file
diff --git a/erpnext/website/doctype/web_page/web_page.txt b/erpnext/website/doctype/web_page/web_page.txt
index c40caff..a1fd894 100644
--- a/erpnext/website/doctype/web_page/web_page.txt
+++ b/erpnext/website/doctype/web_page/web_page.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-04-02 16:02:43',
+ 'creation': '2012-06-19 15:02:20',
'docstatus': 0,
- 'modified': '2012-05-02 15:24:31',
+ 'modified': '2012-06-22 18:49:02',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -36,13 +36,15 @@
# These values are common for all DocPerm
{
+ 'amend': 0,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Web Page',
'parentfield': u'permissions',
'parenttype': u'DocType',
'read': 1,
- 'role': u'Website Manager'
+ 'role': u'Website Manager',
+ 'submit': 0
},
# DocType, Web Page
@@ -53,6 +55,7 @@
# DocPerm
{
+ 'cancel': 1,
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
@@ -61,8 +64,11 @@
# DocPerm
{
+ 'cancel': 0,
+ 'create': 0,
'doctype': u'DocPerm',
- 'permlevel': 1
+ 'permlevel': 1,
+ 'write': 0
},
# DocField
@@ -88,6 +94,17 @@
# DocField
{
+ 'colour': u'White:FFF',
+ 'description': u'Page url name (auto-generated) ',
+ 'doctype': u'DocField',
+ 'fieldname': u'page_name',
+ 'fieldtype': u'Data',
+ 'label': u'Page Name',
+ 'permlevel': 1
+ },
+
+ # DocField
+ {
'doctype': u'DocField',
'fieldname': u'cb1',
'fieldtype': u'Column Break',
@@ -101,7 +118,7 @@
'fieldname': u'layout',
'fieldtype': u'Select',
'label': u'Layout',
- 'options': u'Two column with header\nTwo column\nSingle column',
+ 'options': u'Single column\nTwo column\nTwo column with header',
'permlevel': 0
},
@@ -176,6 +193,7 @@
# DocField
{
'colour': u'White:FFF',
+ 'description': u'Add code as <script>',
'doctype': u'DocField',
'fieldname': u'insert_code',
'fieldtype': u'Check',
@@ -215,15 +233,6 @@
# DocField
{
'doctype': u'DocField',
- 'fieldname': u'page_name',
- 'fieldtype': u'Data',
- 'label': u'Page Name',
- 'permlevel': 1
- },
-
- # DocField
- {
- 'doctype': u'DocField',
'fieldname': u'file_list',
'fieldtype': u'Text',
'hidden': 1,
diff --git a/erpnext/website/doctype/website_settings/website_settings.py b/erpnext/website/doctype/website_settings/website_settings.py
index 9390e74..aec5a39 100644
--- a/erpnext/website/doctype/website_settings/website_settings.py
+++ b/erpnext/website/doctype/website_settings/website_settings.py
@@ -54,8 +54,13 @@
from webnotes.cms.make import make_web_core
make_web_core()
- get_obj('Page', 'blog').write_cms_page(force=True)
- get_obj('Page', 'Login Page').write_cms_page(force=True)
+ import website.web_cache
+ for page in ['blog', 'products']:
+ 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')
diff --git a/erpnext/website/doctype/website_settings/website_settings.txt b/erpnext/website/doctype/website_settings/website_settings.txt
index 368f963..3ae0fbe 100644
--- a/erpnext/website/doctype/website_settings/website_settings.txt
+++ b/erpnext/website/doctype/website_settings/website_settings.txt
@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
- 'creation': '2012-05-03 18:43:46',
+ 'creation': '2012-05-21 15:54:09',
'docstatus': 0,
- 'modified': '2012-05-21 14:59:25',
+ 'modified': '2012-07-09 16:20:58',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -18,7 +18,7 @@
'doctype': 'DocType',
'document_type': u'Other',
'issingle': 1,
- 'max_attachments': 1,
+ 'max_attachments': 10,
'module': u'Website',
'name': '__common__',
'section_style': u'Simple',
@@ -180,21 +180,21 @@
# DocField
{
'doctype': u'DocField',
- 'fieldname': u'file_list',
- 'fieldtype': u'Text',
- 'hidden': 1,
- 'label': u'File List',
- 'no_copy': 1,
- 'permlevel': 0,
- 'print_hide': 1
+ 'fieldname': u'misc_section',
+ 'fieldtype': u'Section Break',
+ 'label': u'Misc',
+ 'permlevel': 0
},
# DocField
{
+ 'colour': u'White:FFF',
+ 'description': u'An icon file with .ico extension. Should be 16 x 16 px. Generated using a favicon generator. [<a href="http://favicon-generator.org/" target="_blank">favicon-generator.org</a>]',
'doctype': u'DocField',
- 'fieldname': u'domains',
- 'fieldtype': u'Section Break',
- 'label': u'Domains',
+ 'fieldname': u'favicon',
+ 'fieldtype': u'Select',
+ 'label': u'FavIcon',
+ 'options': u'attach_files:',
'permlevel': 0
},
@@ -224,6 +224,18 @@
# DocField
{
'doctype': u'DocField',
+ 'fieldname': u'file_list',
+ 'fieldtype': u'Text',
+ 'hidden': 1,
+ 'label': u'File List',
+ 'no_copy': 1,
+ 'permlevel': 0,
+ 'print_hide': 1
+ },
+
+ # DocField
+ {
+ 'doctype': u'DocField',
'fieldname': u'analytics',
'fieldtype': u'Section Break',
'label': u'Startup',
diff --git a/erpnext/website/js/product_category.js b/erpnext/website/js/product_category.js
index 8d3f898..bed4d24 100644
--- a/erpnext/website/js/product_category.js
+++ b/erpnext/website/js/product_category.js
@@ -18,7 +18,10 @@
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" \
+ 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) {
@@ -26,5 +29,6 @@
data);
}
});
- wrapper.category_list.run();
+ wrapper.category_list.run();
+ console.log('product categories made');
}
diff --git a/erpnext/website/product.py b/erpnext/website/product.py
new file mode 100644
index 0000000..7c6603a
--- /dev/null
+++ b/erpnext/website/product.py
@@ -0,0 +1,97 @@
+import webnotes
+
+@webnotes.whitelist(allow_guest=True)
+def get_product_list(args=None):
+ """
+ args = {
+ 'limit_start': 0,
+ 'limit_page_length': 20,
+ 'search': '',
+ 'product_group': '',
+ }
+ """
+ import webnotes
+ from webnotes.utils import cstr, cint
+
+ if not args: args = webnotes.form_dict
+
+ # dict to be passed to sql function
+ query_args = {
+ 'limit_start': cint(args.get('limit_start')),
+ 'limit_page_length': cint(args.get('limit_page_length'))
+ }
+
+ # base query
+ query = """\
+ select name, item_name, page_name, website_image,
+ description, web_short_description
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1"""
+
+ # search term condition
+ if args.get('search'):
+ query += """
+ and (
+ web_short_description like %(search)s or
+ web_long_description like %(search)s or
+ description like %(search)s or
+ item_name like %(search)s or
+ name like %(search)s
+ )"""
+ query_args['search'] = "%" + cstr(args.get('search')) + "%"
+
+ # product group condition
+ if args.get('product_group') and args.get('product_group') != 'All Products':
+ query += """
+ and item_group = %(product_group)s"""
+ query_args['product_group'] = args.get('product_group')
+
+ # order by
+ query += """
+ order by item_name asc, name asc"""
+
+ if args.get('limit_page_length'):
+ query += """
+ limit %(limit_start)s, %(limit_page_length)s"""
+
+ return webnotes.conn.sql(query, query_args, as_dict=1)
+
+@webnotes.whitelist(allow_guest=True)
+def get_product_category_list():
+ import webnotes
+
+ result = webnotes.conn.sql("""\
+ select count(name) as items, item_group
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1
+ group by item_group
+ order by items desc""", as_dict=1)
+
+ # add All Products link
+ total_count = sum((r.get('items') or 0 for r in result))
+ result = [{'items': total_count, 'item_group': 'All Products'}] + (result or [])
+
+ return result
+
+@webnotes.whitelist(allow_guest=True)
+def get_similar_product_list(args=None):
+ import webnotes
+
+ if not args: args = webnotes.form_dict
+
+ result = webnotes.conn.sql("""\
+ select name, item_name, page_name, website_image,
+ description, web_short_description
+ from `tabItem`
+ where is_sales_item = 'Yes'
+ and docstatus = 0
+ and show_in_website = 1
+ and name != %(product_name)s
+ and item_group = %(product_group)s
+ order by item_name""", args, as_dict=1)
+
+ return result
\ No newline at end of file
diff --git a/erpnext/website/templates/404.html b/erpnext/website/templates/404.html
new file mode 100644
index 0000000..8a30892
--- /dev/null
+++ b/erpnext/website/templates/404.html
@@ -0,0 +1,12 @@
+{% extends "outer.html" %}
+
+{% block content %}
+<div class="content">
+ <div class="layout-wrapper layout-main">
+ <h3>Page missing or moved</h3>
+ <br>
+ <p>We are very sorry for this, but the page you are looking for is missing
+ (this could be because of a typo in the address) or moved.</p>
+ </div>
+</div>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/__init__.py b/erpnext/website/templates/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/erpnext/website/templates/__init__.py
diff --git a/erpnext/website/templates/base.html b/erpnext/website/templates/base.html
new file mode 100644
index 0000000..8639a8f
--- /dev/null
+++ b/erpnext/website/templates/base.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<head>
+ <meta charset="utf-8">
+ <title>{% block title %}{% endblock %}</title>
+ <meta name="generator" content="wnframework">
+ <script type="text/javascript" src="js/lib/jquery/jquery.min.js"></script>
+ <script type="text/javascript" src="js/all-web.js"></script>
+ <script type="text/javascript" src="js/wn-web.js"></script>
+ <link type="text/css" rel="stylesheet" href="css/all-web.css">
+ <link type="text/css" rel="stylesheet" href="css/wn-web.css">
+
+ {% if favicon %}
+ <link rel="shortcut icon" href="files/{{ favicon }}" type="image/x-icon">
+ <link rel="icon" href="files/{{ favicon }}" type="image/x-icon">
+ {% else %}
+ <link rel="shortcut icon" href="images/favicon.ico" type="image/x-icon">
+ <link rel="icon" href="images/favicon.ico" type="image/x-icon">
+ {% endif %}
+
+
+ {% block header %}
+ {% endblock %}
+</head>
+<body>
+ {% block body %}
+ {% endblock %}
+</body>
\ No newline at end of file
diff --git a/erpnext/website/templates/blog/blog.html b/erpnext/website/templates/blog/blog.html
new file mode 100644
index 0000000..9132e52
--- /dev/null
+++ b/erpnext/website/templates/blog/blog.html
@@ -0,0 +1,61 @@
+{% extends "blog/blog.js" %}
+
+{% block content %}
+ <div class="layout-wrapper layout-wrapper-background">
+ <div class="web-content" id="blog-{{ name }}">
+
+ <div class="layout-main-section">
+ <h2>{{ title }}</h2>
+ <div class="help">By {{ full_name }} on {{ updated }}</div>
+ <br>
+ {{ content_html }}
+ <hr><h3>Comments</h3>
+ <br>
+ <div class="blog-comments">
+ {% for comment in comment_list %}
+ <div class="comment-row">
+ <div class="comment-title">
+ {{ comment.comment_by_fullname }} - {{ comment.comment_date }}:
+ {{ comment.comment_date_type }}
+ </div>
+ <p class="comment-content">{{ comment.comment }}</p>
+ <hr>
+ </div>
+ {% endfor %}
+ </div>
+ </div>
+
+ <div class="layout-side-section">
+ <p><a href="blog.html">All Blogs</a></p>
+ <br />
+ <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>
+ <br />
+ <h4>Recent Posts</h4>
+ <div class="recent-posts" style="min-height: 100px;"></div>
+ </div>
+
+ <div style="clear: both"></div>
+ </div>
+ </div>
+{% endblock %}
+
+{% block css %}
+ <style>
+ .comment-title {
+ color:#777;
+ }
+
+ .comment-content {
+ margin-left: 20px;
+ }
+
+/* .comment-row {
+ padding: 5px 0px;
+ }
+*/ </style>
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/blog/blog.js b/erpnext/website/templates/blog/blog.js
new file mode 100644
index 0000000..3ad1575
--- /dev/null
+++ b/erpnext/website/templates/blog/blog.js
@@ -0,0 +1,105 @@
+{% extends "page.html" %}
+
+{% block javascript %}
+// 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/>.
+
+// js inside blog page
+wn.provide('erpnext.blog');
+wn.pages['{{ name }}'].onload = function(wrapper) {
+ erpnext.blog.wrapper = wrapper;
+
+ // sidebar
+ wrapper.recent_list = new wn.ui.Listing({
+ parent: $(wrapper).find('.recent-posts'),
+ no_toolbar: true,
+ query: 'select name, title, left(content, 100) as content from tabBlog\
+ where ifnull(published,0)=1 and name!="{{ name }}" order by creation desc',
+ hide_refresh: true,
+ render_row: function(parent, data) {
+ //console.log(data);
+ if(data.content && data.content.length==100) data.content += '...';
+ parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
+ <div class="comment">%(content)s</div><br>', data);
+
+ // adjust page height depending on sidebar height
+ erpnext.blog.adjust_page_height(wrapper);
+ },
+ page_length: 5,
+ });
+ wrapper.recent_list.run();
+}
+
+erpnext.blog.adjust_page_height = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.blog.wrapper; }
+ if (!wrapper) { return; }
+
+ // adjust page height based on sidebar height
+ var $main_page = $(wrapper).find('.layout-main-section');
+ var $sidebar = $(wrapper).find('.layout-side-section');
+ if ($sidebar.height() > $main_page.height()) {
+ $main_page.height($sidebar.height());
+ }
+}
+ // wrapper.comment_list = new wn.ui.Listing({
+ // parent: $(wrapper).find('.blog-comments').get(0),
+ // no_toolbar: true,
+ // query: 'select comment, comment_by_fullname, creation\
+ // from `tabComment` where comment_doctype="Page"\
+ // and comment_docname="{{ name }}" order by creation desc',
+ // no_result_message: 'Be the first one to comment',
+ // render_row: function(parent, data) {
+ // data.comment_date = prettyDate(data.creation);
+ // $(parent).html(repl("<div style='color:#777'>\
+ // %(comment_by_fullname)s | %(comment_date)s:\
+ // </div>\
+ // <p style='margin-left: 20px;'>%(comment)s</p><br>", data))
+ // },
+ // hide_refresh: true,
+ // });
+ // wrapper.comment_list.run();
+ //
+ // // add comment
+ // $(wrapper).find('.layout-main-section').append('<br><button class="btn add-comment">\
+ // Add Comment</button>');
+ // $(wrapper).find('button.add-comment').click(function(){
+ // d = new wn.widgets.Dialog({
+ // title: 'Add Comment',
+ // fields: [
+ // {fieldname:'comment_by_fullname', label:'Your Name', reqd:1, fieldtype:'Data'},
+ // {fieldname:'comment_by', label:'Email Id', reqd:1, fieldtype:'Data'},
+ // {fieldname:'comment', label:'Comment', reqd:1, fieldtype:'Text'},
+ // {fieldname:'post', label:'Post', fieldtype:'Button'}
+ // ]
+ // });
+ // d.fields_dict.post.input.onclick = function() {
+ // var btn = this;
+ // var args = d.get_values();
+ // if(!args) return;
+ // args.comment_doctype = 'Page';
+ // args.comment_docname = '{{ name }}';
+ // $(btn).set_working();
+ // $c('webnotes.widgets.form.comments.add_comment', args, function(r) {
+ // $(btn).done_working();
+ // d.hide();
+ // wrapper.comment_list.refresh();
+ // })
+ // }
+ // d.show();
+ // })
+
+
+{% endblock %}
diff --git a/erpnext/website/templates/blog/blog_list.html b/erpnext/website/templates/blog/blog_list.html
new file mode 100644
index 0000000..242f814
--- /dev/null
+++ b/erpnext/website/templates/blog/blog_list.html
@@ -0,0 +1,43 @@
+{% extends "blog/blog_list.js" %}
+
+{% block title %}Blog{% endblock %}
+
+{% block css %}
+ <style>
+ h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
+ h2 > a:hover, h2 > a:focus {
+ text-decoration: none;
+ color: inherit;
+ }
+ </style>
+{% endblock %}
+
+{% block content %}
+ <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">
+ <!-- blog list will be generated dynamically -->
+ </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>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/blog/blog_list.js b/erpnext/website/templates/blog/blog_list.js
new file mode 100644
index 0000000..70628c1
--- /dev/null
+++ b/erpnext/website/templates/blog/blog_list.js
@@ -0,0 +1,48 @@
+{% extends "page.html" %}
+
+{% block javascript %}
+// 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/>.
+
+// js inside blog page
+wn.pages['{{ name }}'].onload = function(wrapper) {
+ erpnext.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 += repl('... <a href="%(name)s.html">(read on)</a>', data);
+ }
+ 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><a href="%(name)s.html">%(title)s</a></h2>\
+ <p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
+ <p>%(content)s</p><br>', data)
+ //<a href="%(name)s.html">Read Full Text</a><br>', data);
+ },
+ page_length: 10
+ });
+ erpnext.blog_list.run();
+}
+
+{% endblock %}
diff --git a/erpnext/website/templates/login/login.html b/erpnext/website/templates/login/login.html
new file mode 100644
index 0000000..62d252f
--- /dev/null
+++ b/erpnext/website/templates/login/login.html
@@ -0,0 +1,57 @@
+{% extends "login/login.js" %}
+
+{% block title %}
+ Login Page
+{% endblock %}
+
+{% block content %}
+ <div class="layout-wrapper layout-wrapper-appframe" id='login_wrapper'>
+ <div class="appframe-area"></div>
+ <div class="layout-main" style="padding: 15px;">
+ <form autocomplete="on">
+ <table border="0" cellspacing="8">
+ <tbody>
+ <tr>
+ <td>Login Id</td>
+ <td><input id="login_id" type="text" style="width: 180px"/></td>
+ </tr>
+ <tr>
+ <td>Password</td>
+ <td><input id="password" type="password" style="width: 180px" /></td>
+ </tr>
+ <tr>
+ <td style="text-align:right"><input id="remember_me" type="checkbox" /></td>
+ <td>Remember Me</td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td id="login_message"> </td>
+ </tr>
+ <tr>
+ <td> </td>
+ <td>
+ <button type="submit" id="login_btn" class="btn btn-small btn-primary">Login</button>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </form>
+ <p style="margin-left: 72px;"><span class="link_type"
+ onclick="erpnext.login.show_forgot_password()">Forgot Password</span></p>
+ </div>
+ </div>
+
+{% endblock %}
+
+{% block css %}
+ <style>
+ #login_wrapper {
+ width: 300px !important;
+ margin: 20px auto;
+ }
+
+ .login-banner {
+ margin-bottom: 20px;
+ }
+ </style>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/login/login.js b/erpnext/website/templates/login/login.js
new file mode 100644
index 0000000..d6b6b24
--- /dev/null
+++ b/erpnext/website/templates/login/login.js
@@ -0,0 +1,103 @@
+{% extends "page.html" %}
+
+{% block javascript %}
+{{ super() }}
+// 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.
+//
+
+wn.provide('erpnext.login');
+
+wn.pages["{{ name }}"].onload = function(wrapper) {
+ wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'));
+ wrapper.appframe.title('Login');
+ wrapper.appframe.$w.find('.close').toggle(false);
+
+ var lw = $i('login_wrapper');
+ $bs(lw, '1px 1px 3px #888');
+
+ $('#login_btn').click(erpnext.login.doLogin)
+
+ $('#password').keypress(function(ev){
+ if(ev.which==13 && $('#password').val()) {
+ $('form').submit(function() {
+ erpnext.login.doLogin();
+ return false;
+ });
+ }
+ });
+ $(document).trigger('login_rendered');
+}
+
+// Login Callback
+erpnext.login.onLoginReply = function(r, rtext) {
+ $('#login_btn').done_working();
+ if(r.message=="Logged In"){
+ window.location.href='app.html' + (get_url_arg('page') ? ('?page='+get_url_arg('page')) : '');
+ } else {
+ $i('login_message').innerHTML = '<span style="color: RED;">'+(r.message)+'</span>';
+ //if(r.exc)alert(r.exc);
+ }
+}
+
+
+// Login
+erpnext.login.doLogin = function(){
+
+ var args = {};
+ args['usr']=$i("login_id").value;
+ args['pwd']=$i("password").value;
+ if($i('remember_me').checked)
+ args['remember_me'] = 1;
+
+ $('#login_btn').set_working();
+
+ $c("login", args, erpnext.login.onLoginReply);
+
+ return false;
+}
+
+
+erpnext.login.show_forgot_password = function(){
+ // create dialog
+ var d = new wn.ui.Dialog({
+ title:"Forgot Password",
+ fields: [
+ {'label':'Email Id', 'fieldname':'email_id', 'fieldtype':'Data', 'reqd':true},
+ {'label':'Email Me A New Password', 'fieldname':'run', 'fieldtype':'Button'}
+ ]
+ });
+
+ $(d.fields_dict.run.input).click(function() {
+ var values = d.get_values();
+ if(!values) return;
+ wn.call({
+ method:'reset_password',
+ args: { user: values.email_id },
+ callback: function() {
+ d.hide();
+ }
+ })
+ })
+ d.show();
+}
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/outer.html b/erpnext/website/templates/outer.html
new file mode 100644
index 0000000..4b8c04d
--- /dev/null
+++ b/erpnext/website/templates/outer.html
@@ -0,0 +1,57 @@
+{#
+ requires, brand, top_bar_items, footer_items, copyright, content
+#}
+
+{% extends "base.html" %}
+
+{% block body %}
+
+ <header>
+ <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>
+ </header>
+ <div id="body_div">
+ <div class="content" id="page-{{ name }}" style="display: block;">
+ {% block content %}
+ {% endblock %}
+ </div>
+ </div>
+ <footer><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>
+ </footer>
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/page.html b/erpnext/website/templates/page.html
new file mode 100644
index 0000000..c6e0715
--- /dev/null
+++ b/erpnext/website/templates/page.html
@@ -0,0 +1,39 @@
+{% extends "outer.html" %}
+
+{% block title %}{{ title }}{% endblock %}
+
+{% block header %}
+ {{ super() }}
+ {% if insert_code %}
+ <script>
+ window.page_name = "{{ name }}";
+
+ $(document).bind('app_ready', function() {
+ var _page = new wn.views.Page(window.page_name);
+
+ // page script
+ {% block javascript %}
+ {{ javascript }}
+ {% endblock %}
+
+ // trigger onload
+ _page.trigger('onload');
+
+ // activate page
+ wn.container.change_to(window.page_name);
+ });
+ </script>
+ {% endif %}
+
+ {% block css %}
+ {% if insert_style %}
+
+ <style>{{ css }}</style>
+
+ {% endif %}
+ {% endblock %}
+{% endblock %}
+
+{% block content %}
+ {{ content }}
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/product/product.html b/erpnext/website/templates/product/product.html
new file mode 100644
index 0000000..6f33ec9
--- /dev/null
+++ b/erpnext/website/templates/product/product.html
@@ -0,0 +1,77 @@
+{% extends "product/product.js" %}
+
+{% block title %}
+ {% if item_name != name %}
+ {{ item_name }} [{{ name }}]
+ {% else %}
+ {{ item_name }}
+ {% endif %}
+{% endblock %}
+
+{% block content %}
+ <div class="layout-wrapper layout-wrapper-background">
+ <div class="web-content" id="content-product-{{ name }}">
+ <div class="layout-main-section">
+ <h1>{{ item_name }}</h1>
+ <div class="product-page-content">
+ <br><br>
+ {% if website_image %}
+ <image src="files/{{ website_image }}" />
+ {% else %}
+ <div class="img-area"></div>
+ <span style="font-size: 11px">This is an auto-generated Image</span>
+ {% endif %}
+ <br><br>
+ <div class="web-long-description">
+ {{ web_description_html }}
+ </div>
+ </div>
+ </div>
+ <div class="layout-side-section">
+ <h4>More Categories</h4>
+ <div class="more-categories"></div>
+ <br>
+ <h4>Similar Products</h4>
+ <div class="similar-products"></div>
+ </div>
+ <div style="clear: both"></div>
+ </div>
+ </div>
+{% 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 %}
diff --git a/erpnext/website/templates/product/product.js b/erpnext/website/templates/product/product.js
new file mode 100644
index 0000000..f7745d7
--- /dev/null
+++ b/erpnext/website/templates/product/product.js
@@ -0,0 +1,96 @@
+{% extends "product/product_category.js" %}
+
+{% block javascript %}
+{{ super() }}
+// 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.products');
+wn.pages['{{ name }}'].onload = function(wrapper) {
+ wrapper.product_group = "{{ item_group }}";
+ wrapper.product_name = "{{ name }}";
+ erpnext.products.make_product_categories(wrapper);
+ erpnext.products.make_similar_products(wrapper);
+
+ // if website image missing, autogenerate one
+ var $img = $(wrapper).find('.product-page-content .img-area');
+ if ($img && $img.length > 0) {
+ $img.append(wn.dom.placeholder(160, "{{ item_name }}"));
+ }
+
+ erpnext.products.adjust_page_height(wrapper);
+
+}
+
+erpnext.products.adjust_page_height = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.products.wrapper; }
+ if (!wrapper) { return; }
+
+ // adjust page height based on sidebar height
+ var $main_page = $(wrapper).find('.layout-main-section');
+ var $sidebar = $(wrapper).find('.layout-side-section');
+ if ($sidebar.height() > $main_page.height()) {
+ $main_page.height($sidebar.height());
+ }
+}
+
+erpnext.products.make_similar_products = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.products.wrapper; }
+ if (!wrapper) { return; }
+
+ // similar products
+ wrapper.similar = new wn.ui.Listing({
+ parent: $(wrapper).find('.similar-products').get(0),
+ hide_refresh: true,
+ page_length: 5,
+ method: 'website.product.get_similar_product_list',
+ get_args: function() {
+ return {
+ product_group: wrapper.product_group,
+ product_name: wrapper.product_name
+ }
+ },
+ render_row: function(parent, data) {
+ if (!data.web_short_description) {
+ data.web_short_description = data.description;
+ }
+ if(data.web_short_description.length > 100) {
+ data.web_short_description =
+ data.web_short_description.substr(0,100) + '...';
+ }
+ parent.innerHTML = repl('\
+ <a href="%(page_name)s.html"><div class="img-area"></div></a>\
+ <div class="similar-product-description">\
+ <h5><a href="%(page_name)s.html">%(item_name)s</a></h5>\
+ <span>%(web_short_description)s</span>\
+ </div>\
+ <div style="clear:both"></div>', data);
+
+ if(data.website_image) {
+ $(parent).find('.img-area').append(repl(
+ '<img src="files/%(website_image)s" />', data))
+ } else {
+ $(parent).find('.img-area').append(wn.dom.placeholder(55,
+ data.item_name));
+ }
+
+ // adjust page height, if sidebar height keeps increasing
+ erpnext.products.adjust_page_height(wrapper);
+ }
+ });
+ wrapper.similar.run();
+}
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/product/product_category.js b/erpnext/website/templates/product/product_category.js
new file mode 100644
index 0000000..e1905ac
--- /dev/null
+++ b/erpnext/website/templates/product/product_category.js
@@ -0,0 +1,22 @@
+{% extends "page.html" %}
+
+{% block javascript %}
+wn.provide('erpnext.products');
+erpnext.products.make_product_categories = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.products.wrapper; }
+ if (!wrapper) { return; }
+
+ wrapper.category_list = new wn.ui.Listing({
+ parent: $(wrapper).find('.more-categories').get(0),
+ method: 'website.product.get_product_category_list',
+ hide_refresh: true,
+ render_row: function(parent, data) {
+ parent.innerHTML = repl(
+ '<a href="products.html#!products/%(item_group)s">%(item_group)s</a> (%(items)s)',
+ data);
+ }
+ });
+ wrapper.category_list.run();
+}
+
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/product/product_list.html b/erpnext/website/templates/product/product_list.html
new file mode 100644
index 0000000..c8dfd24
--- /dev/null
+++ b/erpnext/website/templates/product/product_list.html
@@ -0,0 +1,43 @@
+{% extends "product/product_list.js" %}
+
+{% block title %}
+ Products
+{% endblock %}
+
+{% block content %}
+ <div class="layout-wrapper layout-wrapper-background">
+ <div class="web-content" 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 id="products-list">
+ <!-- product list will be generated dynamically -->
+ </div>
+ </div>
+
+ <div class="layout-side-section">
+ <h3>Categories</h3>
+ <div class="more-categories"></div>
+ </div>
+ <div style="clear: both"></div>
+ </div>
+ </div>
+{% endblock %}
+
+{% block css %}
+ <style>
+ .img-area {
+ float:left;
+ width: 115px;
+ }
+
+ .product-list-description {
+ float:left;
+ width: 400px;
+ }
+ </style>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/templates/product/product_list.js b/erpnext/website/templates/product/product_list.js
new file mode 100644
index 0000000..1c6f934
--- /dev/null
+++ b/erpnext/website/templates/product/product_list.js
@@ -0,0 +1,112 @@
+{% extends "product/product_category.js" %}
+
+{% block javascript %}
+{{ super() }}
+
+// 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/>.
+
+// js inside blog page
+wn.provide('erpnext.products');
+
+wn.pages['{{ name }}'].onload = function(wrapper) {
+ erpnext.products.wrapper = wrapper;
+
+ // make product categories in the sidebar
+ erpnext.products.make_product_categories(wrapper);
+
+ // make lists
+ erpnext.products.make_product_list(wrapper);
+
+ // bind search button or enter key
+ $(wrapper).find('.products-search .btn').click(function() {
+ erpnext.products.product_list.run();
+ });
+
+ $(wrapper).find('.products-search input').keypress(function(ev) {
+ if(ev.which==13) $(wrapper).find('.products-search .btn').click();
+ });
+}
+
+erpnext.products.make_product_list = function(wrapper) {
+ if (!wrapper) { wrapper = erpnext.products.wrapper; }
+ if (!wrapper) { return; }
+
+ erpnext.products.product_list = new wn.ui.Listing({
+ parent: $(wrapper).find('#products-list').get(0),
+ run_btn: $(wrapper).find('.products-search .btn').get(0),
+ no_toolbar: true,
+ method: 'website.product.get_product_list',
+ get_args: function() {
+ return {
+ search: $('input[name="products-search"]').val() || '',
+ product_group: erpnext.products.cur_group || '',
+ };
+ },
+ render_row: function(parent, data) {
+ if (!data.web_short_description) {
+ data.web_short_description = data.description;
+ }
+ parent.innerHTML = repl('\
+ <a href="%(page_name)s.html"><div class="img-area"></div></a>\
+ <div class="product-list-description">\
+ <h4><a href="%(page_name)s.html">%(item_name)s</a></h4>\
+ <p>%(web_short_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(100,
+ data.item_name));
+ }
+ }
+ });
+}
+
+wn.pages['{{ name }}'].onshow = function(wrapper) {
+ // show default product category
+ erpnext.products.set_group();
+}
+
+erpnext.products.set_group = function() {
+ var cat = erpnext.products.get_group();
+
+ // get erpnext.products.default_category
+ var wrapper = erpnext.products.wrapper;
+
+ $(wrapper).find('h1').html(cat.label);
+ erpnext.products.product_list.run();
+}
+
+erpnext.products.get_group = function() {
+ route = wn.get_route();
+ if(route && route.length>1) {
+ // from url
+ var grp = route[1];
+ var label = route[1];
+ erpnext.products.cur_group = grp;
+ } else {
+ // default
+ var grp = 'Products';
+ var label = 'Products';
+ erpnext.products.cur_group = null;
+ }
+ return {grp:grp, label:label};
+}
+
+{% endblock %}
diff --git a/erpnext/website/templates/web_page.html b/erpnext/website/templates/web_page.html
new file mode 100644
index 0000000..8188e71
--- /dev/null
+++ b/erpnext/website/templates/web_page.html
@@ -0,0 +1,23 @@
+{% extends "page.html" %}
+
+{% block content %}
+ <div class="layout-wrapper layout-wrapper-background">
+ <div class="web-content" style="text-align: {{ text_align }};">
+
+ {% if layout and layout.startswith('Two column') %}
+ <div class="layout-main-section">
+ {% else %}
+ <div class="layout-main">
+ {% endif %}
+ {{ main_section_html }}
+ </div>
+
+ {% if layout and layout.startswith('Two column') %}
+ <div class="layout-side-section">
+ {{ side_section_html }}
+ </div>
+ {% endif %}
+ <div style="clear: both"></div>
+ </div>
+ </div>
+{% endblock %}
\ No newline at end of file
diff --git a/erpnext/website/utils.py b/erpnext/website/utils.py
index 57e940a..06bb60d 100644
--- a/erpnext/website/utils.py
+++ b/erpnext/website/utils.py
@@ -29,43 +29,12 @@
return temp.render(doc = doc.fields)
-def markdown(doc, fields):
- """convert fields to markdown"""
- import markdown2
- # markdown
- for f in fields:
- doc.fields[f + '_html'] = markdown2.markdown(doc.fields[f] or '', \
- extras=["wiki-tables"])
-
-
def page_name(title):
- """make page name from title, and check that there is no duplicate"""
- import webnotes.cms
- return webnotes.cms.page_name(title)
-
-def add_page(title):
- """add a custom page with title"""
- name = page_name(title)
- if webnotes.conn.sql("""select name from tabPage where name=%s""", name):
- p = Document('Page', name)
- else:
- p = Document('Page')
-
- p.title = title
- p.name = p.page_name = name
- p.module = 'Website'
- p.standard = 'No'
-
- return p
-
-def add_guest_access_to_page(page):
- """add Guest in Page Role"""
- if not webnotes.conn.sql("""select parent from `tabPage Role`
- where role='Guest' and parent=%s""", page):
- d = Document('Page Role')
- d.parent = page
- d.role = 'Guest'
- d.save()
+ """make page name from title"""
+ import re
+ name = title.lower()
+ name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
+ return '-'.join(name.split()[:4])
def get_header(page_name):
"""get page header"""
@@ -144,4 +113,4 @@
{% endfor %}
</ul></div>
<div class="web-footer-copyright">© {{ copyright }}
- </div>""").render(website_settings.fields)
+ </div>""").render(website_settings.fields)
\ No newline at end of file
diff --git a/erpnext/website/web_cache.py b/erpnext/website/web_cache.py
new file mode 100644
index 0000000..5fcae82
--- /dev/null
+++ b/erpnext/website/web_cache.py
@@ -0,0 +1,173 @@
+# 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/>.
+
+# used by web.py
+def load_from_web_cache(page_name, comments, template): #, script=None):
+ """
+ * search for page in cache
+ * if html exists, return
+ * if not, build html, store it in cache, return
+ """
+ import webnotes
+ import conf
+
+ if page_name == 'index':
+ page_name = get_index_page()[0]
+
+ res = webnotes.conn.sql("""\
+ select html, doc_type, doc_name from `tabWeb Cache`
+ where name = %s""", page_name)
+
+ # if page doesn't exist, raise exception
+ page_exception_list = ['404', 'index', 'blog', 'products', 'login-page']
+ if not res and page_name not in page_exception_list:
+ 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"
+ html = load_into_web_cache(page_name, template, doc_type, doc_name)
+ else:
+ comments += "\n\npage load status: cached"
+
+ from webnotes.utils import cstr
+ html += """\n<!-- %s -->""" % cstr(comments)
+
+ # show error in error console
+ # if script: html += """\n\n<script>\n%s\n</script>""" % cstr(script)
+ return html
+
+def load_into_web_cache(page_name, template, doc_type, doc_name):
+ """build html and store it in web cache"""
+ import webnotes
+ outer_env_dict = get_outer_env()
+
+ if page_name in ['404', 'blog', 'products', 'login-page']:
+ args = outer_env_dict
+ args.update({
+ 'name': page_name,
+ })
+ else:
+ if page_name == 'index':
+ page_name, doc_type, doc_name = get_index_page()
+
+ from webnotes.model.code import get_obj
+ obj = get_obj(doc_type, doc_name)
+ if hasattr(obj, 'get_html'):
+ obj.get_html()
+ args = obj.doc.fields
+ args.update(outer_env_dict)
+
+ # decide template and update 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)
+
+ # save html in web cache
+ webnotes.conn.begin()
+ webnotes.conn.set_value('Web Cache', page_name, 'html', html)
+ webnotes.conn.commit()
+
+ return html
+
+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():
+ """env dict for outer template"""
+ import webnotes
+ return {
+ '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),
+
+ '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),
+
+ 'brand': webnotes.conn.get_value('Website Settings', None, 'brand_html'),
+ 'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'),
+ 'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon')
+ }
+
+def get_index_page():
+ import webnotes
+ doc_type = 'Web Page'
+ doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
+ page_name = webnotes.conn.get_value(doc_type, doc_name, 'page_name')
+ return page_name, doc_type, doc_name
+
+# cache management
+def clear_web_cache(doc_type, doc_name, 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
+ res = webnotes.conn.get_value('Web Cache', page_name, 'doc_type')
+ if not res:
+ 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()
+ elif res == doc_type:
+ webnotes.conn.set_value('Web Cache', page_name, 'html', None)
+ else:
+ webnotes.msgprint("""Page with name "%s" already exists as a %s.
+ Please save it with another name.""" % (page_name, res), raise_exception=1)
+
+def clear_all_web_cache():
+ import webnotes
+ webnotes.conn.sql("update `tabWeb Cache` set html = NULL")
+
+def delete_web_cache(page_name):
+ """
+ delete entry of page_name from Web Cache
+ used when:
+ * web page is deleted
+ * blog is un-published
+ """
+ import webnotes
+ webnotes.conn.sql("""\
+ delete from `tabWeb Cache`
+ where name=%s""", page_name)
+
+def build_web_cache():
+ """build web cache so that pages can load faster"""
+ pass
\ No newline at end of file
diff --git a/erpnext/website/web_page.py b/erpnext/website/web_page.py
new file mode 100644
index 0000000..58ff40b
--- /dev/null
+++ b/erpnext/website/web_page.py
@@ -0,0 +1,79 @@
+# 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
+import website.utils
+import website.web_cache
+
+class Page(object):
+ def __init__(self, doctype):
+ self.doctype = doctype
+
+ def autoname(self):
+ """name from title"""
+ self.doc.name = website.utils.page_name(self.doc.title)
+
+ def validate(self):
+ if self.doc.name:
+ self.old_page_name = webnotes.conn.get_value(self.doctype, self.doc.name, 'page_name')
+
+ def on_update(self):
+ # page name updates with the title
+ self.update_page_name()
+
+ self.clear_web_cache()
+
+ self.doc.save()
+
+ def on_trash(self):
+ """delete Web Cache entry"""
+ self.delete_web_cache(self.doc.page_name)
+
+ def update_page_name(self):
+ """set page_name and check if it is unique"""
+ self.doc.page_name = website.utils.page_name(self.doc.title)
+
+ res = webnotes.conn.sql("""\
+ select count(*) from `tab%s`
+ where page_name=%s and name!=%s""" % (self.doctype, '%s', '%s'),
+ (self.doc.page_name, self.doc.name))
+ if res and res[0][0] > 0:
+ webnotes.msgprint("""A %s with the same title already exists.
+ Please change the title and save again.""" % self.doctype, raise_exception=1)
+
+ def clear_web_cache(self):
+ """
+ if web cache entry doesn't exist, it creates one
+ if duplicate entry exists for another doctype, it raises exception
+ """
+ # delete web cache entry of old name
+ if hasattr(self, 'old_page_name') and self.old_page_name and \
+ self.old_page_name != self.doc.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)
+
+ def delete_web_cache(self, page_name):
+ """delete entry of page name from Web Cache"""
+ website.web_cache.delete_web_cache(page_name)
+
+ def markdown_to_html(self, fields_list):
+ """convert fields from markdown to html"""
+ import markdown2
+ for f in fields_list:
+ field_name = "%s_html" % f
+ self.doc.fields[field_name] = markdown2.markdown(self.doc.fields.get(f) or '', \
+ extras=["wiki-tables"])
\ No newline at end of file
diff --git a/public/js/all-app.js b/public/js/all-app.js
index fd55b16..f8ceac2 100644
--- a/public/js/all-app.js
+++ b/public/js/all-app.js
@@ -252,8 +252,7 @@
wn.route=function(){if(wn.re_route[window.location.hash]){var re_route_val=wn.get_route_str(wn.re_route[window.location.hash]);var cur_route_val=wn.get_route_str(wn._cur_route);if(decodeURIComponent(re_route_val)===decodeURIComponent(cur_route_val)){window.history.back();return;}else{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){if(!wn.boot){return[window.page_name];}
-return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
+wn.get_route=function(route){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();}
@@ -310,13 +309,13 @@
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
this.onrun=a0;if(a0&&a0.callback)
this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
-this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
-args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
+this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){var query=this.get_query?this.get_query():this.query;query=this.add_limits(query);var args={query_max:this.query_max,as_dict:1}
+args.simple_query=query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.args)
$.extend(args,this.args)
if(this.get_args){$.extend(args,this.get_args(opts));}
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
-if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
+if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(query){query+=' LIMIT '+this.start+','+(this.page_length+1);return query}});
/*
* lib/js/wn/ui/filters.js
*/
@@ -390,7 +389,7 @@
/*
* lib/js/wn/request.js
*/
-wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
+wn.provide('wn.request');wn.request.url='server.py';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
throw"Incomplete Request";}}
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
return;}
diff --git a/public/js/all-web.js b/public/js/all-web.js
index 9673ffb..0244801 100644
--- a/public/js/all-web.js
+++ b/public/js/all-web.js
@@ -139,8 +139,7 @@
wn.route=function(){if(wn.re_route[window.location.hash]){var re_route_val=wn.get_route_str(wn.re_route[window.location.hash]);var cur_route_val=wn.get_route_str(wn._cur_route);if(decodeURIComponent(re_route_val)===decodeURIComponent(cur_route_val)){window.history.back();return;}else{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){if(!wn.boot){return[window.page_name];}
-return $.map(wn.get_route_str(route).split('/'),function(r){return decodeURIComponent(r);});}
+wn.get_route=function(route){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();}
@@ -197,13 +196,13 @@
if(me.no_toolbar||me.hide_toolbar){me.$w.find('.list-toolbar-wrapper').toggle(false);}},make_new_doc:function(new_doctype){new_doc(new_doctype);},make_filters:function(){this.filter_list=new wn.ui.FilterList({listobj:this,$parent:this.$w.find('.list-filters').toggle(true),doctype:this.doctype,filter_fields:this.filter_fields});},clear:function(){this.data=[];this.$w.find('.result-list').empty();this.$w.find('.result').toggle(true);this.$w.find('.no-result').toggle(false);this.start=0;},run:function(){var me=this;var a0=arguments[0];var a1=arguments[1];if(a0&&typeof a0=='function')
this.onrun=a0;if(a0&&a0.callback)
this.onrun=a0.callback;if(!a1&&!(a0&&a0.append))
-this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){this.query=this.get_query?this.get_query():this.query;this.add_limits();var args={query_max:this.query_max,as_dict:1}
-args.simple_query=this.query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
+this.start=0;me.set_working(true);wn.call({method:this.opts.method||'webnotes.widgets.query_builder.runquery',args:this.get_call_args(a0),callback:function(r){me.set_working(false);me.render_results(r)},no_spinner:this.opts.no_loading});},set_working:function(flag){this.$w.find('.img-load').toggle(flag);},get_call_args:function(opts){if(!this.method){var query=this.get_query?this.get_query():this.query;query=this.add_limits(query);var args={query_max:this.query_max,as_dict:1}
+args.simple_query=query;}else{var args={limit_start:this.start,limit_page_length:this.page_length}}
if(this.args)
$.extend(args,this.args)
if(this.get_args){$.extend(args,this.get_args(opts));}
return args;},render_results:function(r){if(this.start==0)this.clear();this.$w.find('.btn-more').toggle(false);if(r.message)r.values=r.message;if(r.values&&r.values.length){this.data=this.data.concat(r.values);this.render_list(r.values);this.update_paging(r.values);}else{if(this.start==0){this.$w.find('.result').toggle(false);this.$w.find('.no-result').toggle(true);}}
-if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(){this.query+=' LIMIT '+this.start+','+(this.page_length+1);}});
+if(this.onrun)this.onrun();if(this.callback)this.callback(r);},render_list:function(values){var m=Math.min(values.length,this.page_length);for(var i=0;i<m;i++){this.render_row(this.add_row(),values[i],this,i);}},update_paging:function(values){if(values.length>=this.page_length){this.$w.find('.btn-more').toggle(true);this.start+=this.page_length;}},add_row:function(){return $('<div class="list-row">').appendTo(this.$w.find('.result-list')).get(0);},refresh:function(){this.run();},add_limits:function(query){query+=' LIMIT '+this.start+','+(this.page_length+1);return query}});
/*
* lib/js/wn/ui/filters.js
*/
@@ -277,7 +276,7 @@
/*
* lib/js/wn/request.js
*/
-wn.provide('wn.request');wn.request.url='index.cgi';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
+wn.provide('wn.request');wn.request.url='server.py';wn.request.prepare=function(opts){if(opts.btn)$(opts.btn).set_working();if(opts.show_spinner)set_loading();if(opts.freeze)freeze();if(!opts.args.cmd){console.log(opts)
throw"Incomplete Request";}}
wn.request.cleanup=function(opts,r){if(opts.btn)$(opts.btn).done_working();if(opts.show_spinner)hide_loading();if(opts.freeze)unfreeze();if(wn.boot&&wn.boot.sid&&wn.get_cookie('sid')!=wn.boot.sid){if(!wn.app.logged_out){msgprint('Session Expired. Logging you out');wn.app.logout();}
return;}
diff --git a/public/js/product_category.js b/public/js/product_category.js
deleted file mode 100644
index aac872f..0000000
--- a/public/js/product_category.js
+++ /dev/null
@@ -1,7 +0,0 @@
-
-/*
- * erpnext/website/js/product_category.js
- */
-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" \
- 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();}
\ No newline at end of file
diff --git a/public/index.cgi b/public/server.py
similarity index 100%
rename from public/index.cgi
rename to public/server.py
diff --git a/public/web.py b/public/web.py
new file mode 100755
index 0000000..e70b61c
--- /dev/null
+++ b/public/web.py
@@ -0,0 +1,76 @@
+#!/usr/bin/env python
+
+"""
+return a dynamic page from website templates
+
+all html pages except login-page.html get generated here
+"""
+
+import cgi, cgitb, os, sys
+cgitb.enable()
+
+# import libs
+sys.path.append('..')
+import conf
+sys.path.append('../lib/py')
+sys.path.append(conf.modules_path)
+
+def init():
+ import webnotes
+ webnotes.form = cgi.FieldStorage(keep_blank_values=True)
+ for key in webnotes.form.keys():
+ webnotes.form_dict[key] = webnotes.form.getvalue(key)
+ webnotes.connect()
+
+def respond():
+ import webnotes
+ try:
+ if 'page' in webnotes.form_dict:
+ html = get_html(webnotes.form_dict['page'])
+ else:
+ # show home page
+ html = get_html('index')
+ except Exception, e:
+ html = get_html('404')
+
+ print "Content-Type: text/html"
+ print
+ 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):
+ import webnotes
+ import website.web_cache
+ page_name = scrub_page_name(page_name)
+
+ if page_name == '404':
+ traceback = webnotes.getTraceback()
+
+ # script is used to display traceback in error console
+ args = {
+ 'comments': """error: %s""" % traceback,
+ 'template': '404.html',
+ }
+ # 'script': """(function() {
+ # var error = "ERROR: %s";
+ # console.log(error);
+ # })();""" % traceback.replace('"', '\\"').replace('\n', ' \\\n'),
+ # }
+
+ else:
+ args = {
+ 'comments': """page: %s""" % page_name,
+ 'template': 'page.html',
+ }
+
+ html = website.web_cache.load_from_web_cache(page_name, **args)
+
+ return html
+
+if __name__=="__main__":
+ init()
+ respond()