mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-02 21:18:27 +00:00
moved directory structure
This commit is contained in:
26
website/__init__.py
Normal file
26
website/__init__.py
Normal file
@@ -0,0 +1,26 @@
|
||||
from __future__ import unicode_literals
|
||||
install_docs = [
|
||||
{"doctype":"Role", "role_name":"Blogger", "name":"Blogger"},
|
||||
{"doctype":"Role", "role_name":"Website Manager", "name":"Website Manager"},
|
||||
]
|
||||
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def send_message():
|
||||
from webnotes.model.doc import Document
|
||||
args = webnotes.form_dict
|
||||
|
||||
d = Document('Support Ticket')
|
||||
d.subject = webnotes.form_dict.get('subject', 'Website Query')
|
||||
d.description = webnotes.form_dict.get('message')
|
||||
d.raised_by = webnotes.form_dict.get('sender')
|
||||
|
||||
if not d.description:
|
||||
webnotes.msgprint('Please write something', raise_exception=True)
|
||||
|
||||
if not d.raised_by:
|
||||
webnotes.msgprint('Please give us your email id so that we can write back to you', raise_exception=True)
|
||||
|
||||
d.save()
|
||||
webnotes.msgprint('Thank you!')
|
||||
167
website/blog.py
Normal file
167
website/blog.py
Normal file
@@ -0,0 +1,167 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_blog_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 10,
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select
|
||||
cache.name as name, cache.html as content,
|
||||
blog.owner as owner, blog.creation as published,
|
||||
blog.title as title, (select count(name) from `tabComment` where
|
||||
comment_doctype='Blog' and comment_docname=blog.name) as comments
|
||||
from `tabWeb Cache` cache, `tabBlog` blog
|
||||
where cache.doc_type = 'Blog' and blog.page_name = cache.name
|
||||
order by published desc, name asc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# strip html tags from content
|
||||
import webnotes.utils
|
||||
import website.web_cache
|
||||
|
||||
for res in result:
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
res['full_name'] = get_fullname(res['owner'])
|
||||
res['published'] = global_date_format(res['published'])
|
||||
if not res['content']:
|
||||
res['content'] = website.web_cache.get_html(res['name'])
|
||||
res['content'] = split_blog_content(res['content'])
|
||||
res['content'] = res['content'][:1000]
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_recent_blog_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
'name': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
select name, page_name, title, left(content, 100) as content
|
||||
from tabBlog
|
||||
where ifnull(published,0)=1 and
|
||||
name!=%(name)s order by creation desc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
# strip html tags from content
|
||||
import webnotes.utils
|
||||
for res in result:
|
||||
res['content'] = webnotes.utils.strip_html(res['content'])
|
||||
|
||||
return result
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def add_comment(args=None):
|
||||
"""
|
||||
args = {
|
||||
'comment': '',
|
||||
'comment_by': '',
|
||||
'comment_by_fullname': '',
|
||||
'comment_doctype': '',
|
||||
'comment_docname': '',
|
||||
'page_name': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
import webnotes.utils, markdown2
|
||||
import webnotes.widgets.form.comments
|
||||
import website.web_cache
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
args['comment'] = unicode(markdown2.markdown(args.get('comment') or ''))
|
||||
|
||||
comment = webnotes.widgets.form.comments.add_comment(args)
|
||||
|
||||
# since comments are embedded in the page, clear the web cache
|
||||
website.web_cache.clear_cache(args.get('page_name'),
|
||||
args.get('comment_doctype'), args.get('comment_docname'))
|
||||
|
||||
|
||||
comment['comment_date'] = webnotes.utils.global_date_format(comment['creation'])
|
||||
template_args = { 'comment_list': [comment], 'template': 'html/comment.html' }
|
||||
|
||||
# get html of comment row
|
||||
comment_html = website.web_cache.build_html(template_args)
|
||||
|
||||
# notify commentors
|
||||
commentors = [d[0] for d in webnotes.conn.sql("""select comment_by from tabComment where
|
||||
comment_doctype='Blog' and comment_docname=%s and
|
||||
ifnull(unsubscribed, 0)=0""", args.get('comment_docname'))]
|
||||
|
||||
blog = webnotes.conn.sql("""select * from tabBlog where name=%s""",
|
||||
args.get('comment_docname'), as_dict=1)[0]
|
||||
|
||||
from webnotes.utils.email_lib.bulk import send
|
||||
send(recipients=list(set(commentors + [blog['owner']])),
|
||||
doctype='Comment',
|
||||
email_field='comment_by',
|
||||
first_name_field="comment_by_fullname",
|
||||
last_name_field="NA",
|
||||
subject='New Comment on Blog: ' + blog['title'],
|
||||
message='%(comment)s<p>By %(comment_by_fullname)s</p>' % args)
|
||||
|
||||
return comment_html
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def add_subscriber():
|
||||
"""add blog subscriber to lead"""
|
||||
full_name = webnotes.form_dict.get('your_name')
|
||||
email = webnotes.form_dict.get('your_email_address')
|
||||
name = webnotes.conn.sql("""select name from tabLead where email_id=%s""", email)
|
||||
|
||||
from webnotes.model.doc import Document
|
||||
if name:
|
||||
lead = Document('Lead', name[0][0])
|
||||
else:
|
||||
lead = Document('Lead')
|
||||
|
||||
if not lead.source: lead.source = 'Blog'
|
||||
lead.unsubscribed = 0
|
||||
lead.blog_subscriber = 1
|
||||
lead.lead_name = full_name
|
||||
lead.email_id = email
|
||||
lead.save()
|
||||
|
||||
def get_blog_content(blog_page_name):
|
||||
import website.web_cache
|
||||
content = website.web_cache.get_html(blog_page_name)
|
||||
|
||||
content = split_blog_content(content)
|
||||
|
||||
import webnotes.utils
|
||||
content = webnotes.utils.escape_html(content)
|
||||
|
||||
return content
|
||||
|
||||
def split_blog_content(content):
|
||||
content = content.split("<!-- begin blog content -->")
|
||||
content = len(content) > 1 and content[1] or content[0]
|
||||
|
||||
content = content.split("<!-- end blog content -->")
|
||||
content = content[0]
|
||||
|
||||
return content
|
||||
137
website/css/website.css
Normal file
137
website/css/website.css
Normal file
@@ -0,0 +1,137 @@
|
||||
header .container, .content {
|
||||
width: 900px;
|
||||
}
|
||||
|
||||
div#body_div {
|
||||
padding-top: 80px;
|
||||
min-height: 400px;
|
||||
}
|
||||
|
||||
p, li {
|
||||
line-height: 1.6em;
|
||||
}
|
||||
|
||||
pre {
|
||||
background-color: #F8F8F8;
|
||||
border: 1px solid #CCCCCC;
|
||||
border-radius: 3px 3px 3px 3px;
|
||||
font-size: 13px;
|
||||
line-height: 19px;
|
||||
overflow: auto;
|
||||
padding: 6px 10px;
|
||||
margin-bottom: 9px;
|
||||
}
|
||||
|
||||
.web-head-section {
|
||||
margin-bottom: 20px
|
||||
}
|
||||
|
||||
.web-main-section {
|
||||
width: 65%;
|
||||
float: left;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.web-side-section {
|
||||
width: 30%;
|
||||
float: right;
|
||||
margin-bottom: 20px;
|
||||
margin-right: 15px;
|
||||
color: #606060;
|
||||
overflow-x: hidden;
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
.web-page-status {
|
||||
padding: 7px;
|
||||
margin-top: -20px;
|
||||
color: #777;
|
||||
clear: both;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.web-page-status a,
|
||||
.web-page-status a:hover,
|
||||
.web-page-status a:visited {
|
||||
padding: 2px;
|
||||
background-color: #777;
|
||||
color: #FFF;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.web-page-status a:hover {
|
||||
background-color: #444;
|
||||
}
|
||||
|
||||
|
||||
footer {
|
||||
|
||||
}
|
||||
|
||||
.web-footer-menu {
|
||||
margin-bottom: 7px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul {
|
||||
list-style: none;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul li {
|
||||
display: inline;
|
||||
padding: 2px 15px;
|
||||
border-right: 1px solid #999;
|
||||
}
|
||||
|
||||
.web-footer-menu ul li:first-child {
|
||||
padding-left: 0px;
|
||||
}
|
||||
|
||||
.web-footer-menu ul li:last-child {
|
||||
border-right: 0px solid #777 !important;
|
||||
}
|
||||
|
||||
.web-footer-powered {
|
||||
color: #888;
|
||||
float: right;
|
||||
margin-top: -12px;
|
||||
}
|
||||
|
||||
/* slide view */
|
||||
|
||||
.next-slide {
|
||||
margin: 0px -27px 100px -27px;
|
||||
background: #ffffff; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #eeeeee 0%, #fff 100%); /* FF3.6+ */
|
||||
background: -webkit-linear-gradient(top, #eeeeee 0%, #fff 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #eeeeee 0%, #fff 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #eeeeee 0%, #fff 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #eeeeee 0%, #fff 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#eeeeee', endColorstr='#fff',GradientType=0 ); /* IE6-9 */
|
||||
height: 36px;
|
||||
}
|
||||
|
||||
.slide-shadow {
|
||||
background: #eeeeee; /* Old browsers */
|
||||
background: -moz-linear-gradient(top, #bababa 0%,#eeeeee 100%); /* FF3.6+ */
|
||||
background: -webkit-linear-gradient(top, #bababa 0%,#eeeeee 100%); /* Chrome10+,Safari5.1+ */
|
||||
background: -o-linear-gradient(top, #bababa 0%,#eeeeee 100%); /* Opera 11.10+ */
|
||||
background: -ms-linear-gradient(top, #bababa 0%,#eeeeee 100%); /* IE10+ */
|
||||
background: linear-gradient(top, #bababa 0%,#eeeeee 100%); /* W3C */
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bababa', endColorstr='#eeeeee',GradientType=0 ); /* IE6-9 */
|
||||
height: 3px;
|
||||
margin: 100px -27px 0px -27px;
|
||||
border-top: 1px solid #bababa;
|
||||
}
|
||||
|
||||
.two-column {
|
||||
width: 50%;
|
||||
float: left;
|
||||
}
|
||||
|
||||
.clear {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
/* */
|
||||
1
website/doctype/__init__.py
Normal file
1
website/doctype/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
1
website/doctype/blog/__init__.py
Normal file
1
website/doctype/blog/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
25
website/doctype/blog/blog.js
Normal file
25
website/doctype/blog/blog.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// 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/>.
|
||||
|
||||
cur_frm.cscript.refresh = function(doc) {
|
||||
if(!doc.__islocal && doc.published && !doc.email_sent) {
|
||||
cur_frm.add_custom_button('Email Subscribers', function() {
|
||||
$c_obj(make_doclist(doc.doctype, doc.name), 'send_emails', '', function(r) {
|
||||
cur_frm.refresh();
|
||||
});
|
||||
})
|
||||
}
|
||||
}
|
||||
82
website/doctype/blog/blog.py
Normal file
82
website/doctype/blog/blog.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import webnotes
|
||||
import website.utils
|
||||
import website.web_page
|
||||
|
||||
class DocType(website.web_page.Page):
|
||||
def __init__(self, d, dl):
|
||||
super(DocType, self).__init__('Blog')
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def send_emails(self):
|
||||
"""send emails to subscribers"""
|
||||
if self.doc.email_sent:
|
||||
webnotes.msgprint("""Blog Subscribers already updated""", raise_exception=1)
|
||||
|
||||
from webnotes.utils.email_lib.bulk import send
|
||||
from markdown2 import markdown
|
||||
import webnotes.utils
|
||||
|
||||
# get leads that are subscribed to the blog
|
||||
recipients = [e[0] for e in webnotes.conn.sql("""select distinct email_id from tabLead where
|
||||
ifnull(blog_subscriber,0)=1""")]
|
||||
|
||||
# make heading as link
|
||||
content = '<h2><a href="%s/%s.html">%s</a></h2>\n\n%s' % (webnotes.utils.get_request_site_address(),
|
||||
self.doc.page_name, self.doc.title, markdown(self.doc.content))
|
||||
|
||||
# send the blog
|
||||
send(recipients = recipients, doctype='Lead', email_field='email_id',
|
||||
first_name_field = 'lead_name', last_name_field="", subject=self.doc.title,
|
||||
message = markdown(content))
|
||||
|
||||
webnotes.conn.set(self.doc, 'email_sent', 1)
|
||||
webnotes.msgprint("""Scheduled to send to %s subscribers""" % len(recipients))
|
||||
|
||||
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)
|
||||
else:
|
||||
import website.blog
|
||||
website.blog.get_blog_content(self.doc.page_name)
|
||||
|
||||
def prepare_template_args(self):
|
||||
import webnotes.utils
|
||||
|
||||
# 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!"
|
||||
|
||||
# temp fields
|
||||
from webnotes.utils import global_date_format, get_fullname
|
||||
self.doc.full_name = get_fullname(self.doc.owner)
|
||||
self.doc.updated = global_date_format(self.doc.creation)
|
||||
|
||||
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.global_date_format(comment['creation'])
|
||||
137
website/doctype/blog/blog.txt
Normal file
137
website/doctype/blog/blog.txt
Normal file
@@ -0,0 +1,137 @@
|
||||
# DocType, Blog
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-07-27 19:32:53',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-08-03 12:18:36',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1328599743',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'max_attachments': 5,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Blog',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Blog',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Blog
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Blog'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Website Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Blogger',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'role': u'Guest',
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'title',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Title',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'published',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Published',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'content',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Content',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page_name',
|
||||
'fieldtype': u'Data',
|
||||
'hidden': 1,
|
||||
'label': u'Page Name',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'email_sent',
|
||||
'fieldtype': u'Check',
|
||||
'hidden': 1,
|
||||
'label': u'Email Sent',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# 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
|
||||
}
|
||||
]
|
||||
1
website/doctype/related_page/__init__.py
Normal file
1
website/doctype/related_page/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
49
website/doctype/related_page/related_page.txt
Normal file
49
website/doctype/related_page/related_page.txt
Normal file
@@ -0,0 +1,49 @@
|
||||
# DocType, Related Page
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-03-27 14:36:48',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-03-27 14:36:48',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 3
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'page',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Page',
|
||||
'name': '__common__',
|
||||
'options': u'Page',
|
||||
'parent': u'Related Page',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Related Page
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Related Page'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField'
|
||||
}
|
||||
]
|
||||
1
website/doctype/style_settings/__init__.py
Normal file
1
website/doctype/style_settings/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
26
website/doctype/style_settings/custom_template.css
Normal file
26
website/doctype/style_settings/custom_template.css
Normal file
@@ -0,0 +1,26 @@
|
||||
#body_div {
|
||||
{% if doc.background_image %}
|
||||
background: url("../files/{{ doc.background_image }}") repeat;
|
||||
{% elif doc.background_color %}
|
||||
background-color: #{{ doc.background_color }};
|
||||
background-image: none;
|
||||
{% endif %}
|
||||
{% if doc.font %}
|
||||
font-family: '{{ doc.font }}', Verdana, Sans !important;
|
||||
{% endif %}
|
||||
{% if doc.font_size %}
|
||||
font-size: {{ doc.font_size }} !important;
|
||||
{% endif %}
|
||||
}
|
||||
|
||||
{% if doc.font_size %}
|
||||
.small {
|
||||
font-size: {{ doc.small_font_size }} !important;
|
||||
}
|
||||
{% endif %}
|
||||
|
||||
{% if doc.heading_font %}
|
||||
h1, h2, h3, h4, h5 {
|
||||
font-family: '{{ doc.heading_font}}', Arial, 'Helvetica Neue' !important;
|
||||
}
|
||||
{% endif %}
|
||||
22
website/doctype/style_settings/style_settings.js
Normal file
22
website/doctype/style_settings/style_settings.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// 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('lib/js/lib/jscolor/jscolor.js');
|
||||
|
||||
cur_frm.cscript.onload_post_render = function() {
|
||||
cur_frm.fields_dict.background_color.input.className = 'color';
|
||||
jscolor.bind();
|
||||
}
|
||||
50
website/doctype/style_settings/style_settings.py
Normal file
50
website/doctype/style_settings/style_settings.py
Normal file
@@ -0,0 +1,50 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
"""make custom css"""
|
||||
from jinja2 import Template
|
||||
import os
|
||||
|
||||
with open(os.path.join(
|
||||
os.path.dirname(os.path.abspath(__file__)),
|
||||
'custom_template.css'), 'r') as f:
|
||||
temp = Template(f.read())
|
||||
|
||||
if not self.doc.font_size:
|
||||
self.doc.font_size = '13px'
|
||||
|
||||
self.doc.small_font_size = str(int(self.doc.font_size[:-2])-2) + 'px'
|
||||
|
||||
self.doc.custom_css = temp.render(doc = self.doc)
|
||||
if self.doc.add_css:
|
||||
self.doc.custom_css += '\n\n/* User CSS */\n\n' + self.doc.add_css
|
||||
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
del self.doc.fields['small_font_size']
|
||||
|
||||
def on_update(self):
|
||||
"""rebuild pages"""
|
||||
from webnotes.cms.make import make_web_core
|
||||
make_web_core()
|
||||
|
||||
172
website/doctype/style_settings/style_settings.txt
Normal file
172
website/doctype/style_settings/style_settings.txt
Normal file
@@ -0,0 +1,172 @@
|
||||
# DocType, Style Settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-02 16:02:43',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-01 15:58:16',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1330594969',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Set your background color, font and image (tiled)',
|
||||
'doctype': 'DocType',
|
||||
'issingle': 1,
|
||||
'max_attachments': 1,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Style Settings',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Style Settings',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1,
|
||||
'role': u'Website Manager'
|
||||
},
|
||||
|
||||
# DocType, Style Settings
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Style Settings'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'If image is selected, color will be ignored (attach first)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'background_image',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Background Image',
|
||||
'options': u'attach_files:',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Solid background color (default light gray)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'background_color',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Background Color',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldtype': u'Column Break',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'font',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Font',
|
||||
'options': u'\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'font_size',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Font Size',
|
||||
'options': u'\n12px\n13px\n14px\n15px\n16px',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'heading_font',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Heading Font',
|
||||
'options': u'\nHelvetica Neue\nLucida Grande\nVerdana\nArial\nGeorgia\nTahoma\nLato\nOpen Sans',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'css',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'CSS',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'add your own CSS (careful!)',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'add_css',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Add CSS',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Auto generated',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'custom_css',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Custom CSS',
|
||||
'permlevel': 1
|
||||
},
|
||||
|
||||
# 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
|
||||
}
|
||||
]
|
||||
1
website/doctype/top_bar_item/__init__.py
Normal file
1
website/doctype/top_bar_item/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
75
website/doctype/top_bar_item/top_bar_item.txt
Normal file
75
website/doctype/top_bar_item/top_bar_item.txt
Normal file
@@ -0,0 +1,75 @@
|
||||
# DocType, Top Bar Item
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-04-02 16:02:43',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-05-07 15:21:00',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'istable': 1,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Top Bar Item',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocType, Top Bar Item
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Top Bar Item'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'label',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Label',
|
||||
'width': u'120px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'url',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'URL',
|
||||
'width': u'200px'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'target',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Target',
|
||||
'options': u'\ntarget = "_blank"'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'parent_label',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Parent Label'
|
||||
}
|
||||
]
|
||||
1
website/doctype/web_cache/__init__.py
Normal file
1
website/doctype/web_cache/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
99
website/doctype/web_cache/web_cache.txt
Normal file
99
website/doctype/web_cache/web_cache.txt
Normal file
@@ -0,0 +1,99 @@
|
||||
# DocType, Web Cache
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
u'creation': '2012-07-12 22:19:44',
|
||||
u'docstatus': 0,
|
||||
u'modified': '2012-09-17 10:48:17',
|
||||
u'modified_by': u'Administrator',
|
||||
u'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
u'doctype': u'DocType',
|
||||
'document_type': u'System',
|
||||
'module': u'Website',
|
||||
u'name': u'__common__',
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
u'name': u'__common__',
|
||||
'parent': u'Web Cache',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
u'doctype': u'DocPerm',
|
||||
u'name': u'__common__',
|
||||
'parent': u'Web Cache',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'permlevel': 0,
|
||||
'read': 1,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocType, Web Cache
|
||||
{
|
||||
u'doctype': u'DocType',
|
||||
u'name': u'Web Cache'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'doc_type',
|
||||
'fieldtype': u'Link',
|
||||
'in_filter': 1,
|
||||
'label': u'DocType',
|
||||
'options': u'DocType',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'doc_name',
|
||||
'fieldtype': u'Data',
|
||||
'in_filter': 0,
|
||||
'label': u'DocName',
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
u'doctype': u'DocField',
|
||||
'fieldname': u'html',
|
||||
'fieldtype': u'Long Text',
|
||||
'label': u'HTML'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 0,
|
||||
u'doctype': u'DocPerm',
|
||||
'role': u'Guest'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
u'doctype': u'DocPerm',
|
||||
'role': u'Website Manager'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
u'doctype': u'DocPerm',
|
||||
'role': u'Blogger'
|
||||
}
|
||||
]
|
||||
1
website/doctype/web_page/__init__.py
Normal file
1
website/doctype/web_page/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
33
website/doctype/web_page/web_page.js
Normal file
33
website/doctype/web_page/web_page.js
Normal file
@@ -0,0 +1,33 @@
|
||||
$.extend(cur_frm.cscript, {
|
||||
layout: function(doc) {
|
||||
if(!doc.layout) doc.layout = 'Two column with header'
|
||||
hide_field(['head_section', 'side_section', 'javascript', 'css']);
|
||||
if(doc.layout=='Two column with header') {
|
||||
unhide_field(['head_section', 'side_section']);
|
||||
}
|
||||
if(doc.layout=='Two column') {
|
||||
unhide_field('side_section');
|
||||
}
|
||||
if(doc.insert_code) {
|
||||
if(!doc.javascript) {
|
||||
doc.javascript = 'wn.pages["'+doc.name+'"].onload = function(wrapper) { }';
|
||||
}
|
||||
unhide_field('javascript');
|
||||
}
|
||||
if(doc.insert_style) {
|
||||
if(!doc.css) {
|
||||
doc.css = '#page-'+doc.name+' { }';
|
||||
}
|
||||
unhide_field('css');
|
||||
}
|
||||
},
|
||||
refresh: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
},
|
||||
insert_style: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
},
|
||||
insert_code: function(doc) {
|
||||
cur_frm.cscript.layout(doc);
|
||||
}
|
||||
})
|
||||
41
website/doctype/web_page/web_page.py
Normal file
41
website/doctype/web_page/web_page.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
import website.utils
|
||||
import website.web_page
|
||||
|
||||
class DocType(website.web_page.Page):
|
||||
def __init__(self, d, dl):
|
||||
super(DocType, self).__init__('Web Page')
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def on_update(self):
|
||||
super(DocType, self).on_update()
|
||||
self.if_home_clear_cache()
|
||||
|
||||
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')
|
||||
import website.web_cache
|
||||
website.web_cache.clear_cache(self.doc.page_name)
|
||||
website.web_cache.clear_cache('index')
|
||||
|
||||
def prepare_template_args(self):
|
||||
self.markdown_to_html(['head_section','main_section', 'side_section'])
|
||||
244
website/doctype/web_page/web_page.txt
Normal file
244
website/doctype/web_page/web_page.txt
Normal file
@@ -0,0 +1,244 @@
|
||||
# DocType, Web Page
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-06-19 15:02:20',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-06-22 18:49:02',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1328093379',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'description': u'A custom page is a simple page with the layout - headline, main section, side section\n\nEditing:\n\n- Editing is in [markdown format](http://daringfireball.net/projects/markdown/syntax)\n- You can also add images and embed html code\n\nAccessing the page:\n\n- The page can be accessed as #![page-name] after the main url\n\nIdeal for pages like FAQ, Terms and Conditions, Help etc.\n\n',
|
||||
'doctype': 'DocType',
|
||||
'max_attachments': 20,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Web Page',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# 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',
|
||||
'submit': 0
|
||||
},
|
||||
|
||||
# DocType, Web Page
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Web Page'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 1,
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'cancel': 0,
|
||||
'create': 0,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'write': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sb0',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Title and Style',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Title / headline of your page',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'title',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Title',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# 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',
|
||||
'permlevel': 0,
|
||||
'width': u'50%'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'layout',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Layout',
|
||||
'options': u'Single column\nTwo column\nTwo column with header',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Page content',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sb1',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Content',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Section that will span 2 columns, formatted as markdown. If no head, leave blank. If you are displaying a banner, it must be 860px',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'head_section',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Head Section',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Content in markdown format that appears on the main side of your page',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'main_section',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Main Section',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Content in markdown format that appears on the right side',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'side_section',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Side Section',
|
||||
'options': u'Markdown',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Link to other pages in the side bar and next section',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'sb2',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'More',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'text_align',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'Text Align',
|
||||
'options': u'Left\nCenter\nRight',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Add code as <script>',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'insert_code',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Insert Code',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'javascript',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Javascript',
|
||||
'options': u'Javascript',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'insert_style',
|
||||
'fieldtype': u'Check',
|
||||
'label': u'Insert Style',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'css',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'CSS',
|
||||
'options': u'CSS',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# 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
|
||||
}
|
||||
]
|
||||
1
website/doctype/website_settings/__init__.py
Normal file
1
website/doctype/website_settings/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
44
website/doctype/website_settings/website_settings.js
Normal file
44
website/doctype/website_settings/website_settings.js
Normal file
@@ -0,0 +1,44 @@
|
||||
// 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/>.
|
||||
|
||||
// update parent select
|
||||
|
||||
$.extend(cur_frm.cscript, {
|
||||
|
||||
onload_post_render: function(doc) {
|
||||
// get labels of parent items
|
||||
var get_parent_options = function(table_field) {
|
||||
var items = getchildren('Top Bar Item', doc.name, table_field);
|
||||
var main_items = [''];
|
||||
for(var i in items) {
|
||||
var d = items[i];
|
||||
if(!d.parent_label) {
|
||||
main_items.push(d.label);
|
||||
}
|
||||
}
|
||||
return main_items.join('\n');
|
||||
}
|
||||
|
||||
// bind function to refresh fields
|
||||
// when "Parent Label" is select, it
|
||||
// should automatically update
|
||||
// options
|
||||
$(cur_frm.fields_dict['top_bar_items'].grid.get_field('parent_label').wrapper)
|
||||
.bind('refresh', function() {
|
||||
this.fieldobj.refresh_options(get_parent_options('top_bar_items'));
|
||||
});
|
||||
}
|
||||
});
|
||||
74
website/doctype/website_settings/website_settings.py
Normal file
74
website/doctype/website_settings/website_settings.py
Normal file
@@ -0,0 +1,74 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
class DocType:
|
||||
def __init__(self, d, dl):
|
||||
self.doc, self.doclist = d, dl
|
||||
|
||||
def validate(self):
|
||||
"""
|
||||
* set home page
|
||||
* validate domain list
|
||||
* clear cache
|
||||
"""
|
||||
self.set_home_page()
|
||||
self.validate_domain_list()
|
||||
|
||||
def on_update(self):
|
||||
# make js and css
|
||||
from webnotes.cms.make import make_web_core
|
||||
make_web_core()
|
||||
|
||||
# clear web cache
|
||||
import website.web_cache
|
||||
#website.web_cache.refresh_cache(build=['Blog'])
|
||||
website.web_cache.refresh_cache()
|
||||
|
||||
from webnotes.session_cache import clear_cache
|
||||
clear_cache('Guest')
|
||||
|
||||
def set_home_page(self):
|
||||
|
||||
import webnotes
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
webnotes.conn.sql("""delete from `tabDefault Home Page` where role='Guest'""")
|
||||
|
||||
d = Document('Default Home Page')
|
||||
d.parent = 'Control Panel'
|
||||
d.parenttype = 'Control Panel'
|
||||
d.parentfield = 'default_home_pages'
|
||||
d.role = 'Guest'
|
||||
d.home_page = self.doc.home_page
|
||||
d.save()
|
||||
|
||||
|
||||
def validate_domain_list(self):
|
||||
"""
|
||||
Validate domain list if SaaS
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
try:
|
||||
from server_tools.gateway_utils import validate_domain_list
|
||||
res = validate_domain_list(self.doc.domain_list, webnotes.conn.cur_db_name)
|
||||
if not res:
|
||||
webnotes.msgprint("""\
|
||||
There was some error in validating the domain list.
|
||||
Please contact us at support@erpnext.com""", raise_exception=1)
|
||||
except ImportError, e:
|
||||
pass
|
||||
256
website/doctype/website_settings/website_settings.txt
Normal file
256
website/doctype/website_settings/website_settings.txt
Normal file
@@ -0,0 +1,256 @@
|
||||
# DocType, Website Settings
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-05-21 15:54:09',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-07-09 16:20:58',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all DocType
|
||||
{
|
||||
'_last_update': u'1329115882',
|
||||
'allow_attach': 1,
|
||||
'colour': u'White:FFF',
|
||||
'doctype': 'DocType',
|
||||
'document_type': u'Other',
|
||||
'issingle': 1,
|
||||
'max_attachments': 10,
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'section_style': u'Simple',
|
||||
'show_in_menu': 0,
|
||||
'version': 1
|
||||
},
|
||||
|
||||
# These values are common for all DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'name': '__common__',
|
||||
'parent': u'Website Settings',
|
||||
'parentfield': u'fields',
|
||||
'parenttype': u'DocType'
|
||||
},
|
||||
|
||||
# These values are common for all DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'name': '__common__',
|
||||
'parent': u'Website Settings',
|
||||
'parentfield': u'permissions',
|
||||
'parenttype': u'DocType',
|
||||
'read': 1
|
||||
},
|
||||
|
||||
# DocType, Website Settings
|
||||
{
|
||||
'doctype': 'DocType',
|
||||
'name': u'Website Settings'
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'System Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'create': 1,
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 0,
|
||||
'role': u'Website Manager',
|
||||
'write': 1
|
||||
},
|
||||
|
||||
# DocPerm
|
||||
{
|
||||
'doctype': u'DocPerm',
|
||||
'permlevel': 1,
|
||||
'role': u'All'
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'top_bar',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Top Bar',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'The name of your company / website as you want to appear on browser title bar. All pages will have this as the prefix to the title.',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'title_prefix',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Title Prefix',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'The "Web Page" that is the website home page',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'home_page',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Home Page',
|
||||
'options': u'Web Page',
|
||||
'permlevel': 0,
|
||||
'reqd': 1
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'default_product_category',
|
||||
'fieldtype': u'Link',
|
||||
'label': u'Default Product Category',
|
||||
'options': u'Item Group',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Brand is what appears on the top-right of the toolbar. If it is an image, make sure it\nhas a transparent background and use the <img /> tag',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'brand_html',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Brand HTML',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'top_bar_items',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Top Bar Items',
|
||||
'options': u'Top Bar Item',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'footer',
|
||||
'fieldtype': u'Section Break',
|
||||
'label': u'Footer',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'address',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Address',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'copyright',
|
||||
'fieldtype': u'Data',
|
||||
'label': u'Copyright',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'footer_items',
|
||||
'fieldtype': u'Table',
|
||||
'label': u'Footer Items',
|
||||
'options': u'Top Bar Item',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'doctype': u'DocField',
|
||||
'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'favicon',
|
||||
'fieldtype': u'Select',
|
||||
'label': u'FavIcon',
|
||||
'options': u'attach_files:',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Sub-domain provided by erpnext.com',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'subdomain',
|
||||
'fieldtype': u'Text',
|
||||
'label': u'Subdomain',
|
||||
'permlevel': 1,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'description': u'Enter domain names associated to this website, each on a new line',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'domain_list',
|
||||
'fieldtype': u'Text',
|
||||
'hidden': 1,
|
||||
'label': u'Domain List',
|
||||
'permlevel': 0,
|
||||
'reqd': 0
|
||||
},
|
||||
|
||||
# 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',
|
||||
'permlevel': 0
|
||||
},
|
||||
|
||||
# DocField
|
||||
{
|
||||
'colour': u'White:FFF',
|
||||
'description': u'Bind events on startup and page change',
|
||||
'doctype': u'DocField',
|
||||
'fieldname': u'startup_code',
|
||||
'fieldtype': u'Code',
|
||||
'label': u'Startup Code',
|
||||
'options': u'Javascript',
|
||||
'permlevel': 0
|
||||
}
|
||||
]
|
||||
1
website/page/__init__.py
Normal file
1
website/page/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
27
website/page/unsubscribe/unsubscribe.py
Normal file
27
website/page/unsubscribe/unsubscribe.py
Normal file
@@ -0,0 +1,27 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
@webnotes.whitelist()
|
||||
def unsubscribe(arg):
|
||||
"""unsubscribe from lists"""
|
||||
lists = [['Blog Subscriber', 'name']]
|
||||
for l in lists:
|
||||
webnotes.conn.sql("""delete from `tab%s` where %s=%s""" % (l[0], l[1], '%s'), arg)
|
||||
|
||||
webnotes.msgprint('Unsubscribed!')
|
||||
1
website/page/website_home/__init__.py
Normal file
1
website/page/website_home/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
41
website/page/website_home/website_home.html
Normal file
41
website/page/website_home/website_home.html
Normal file
@@ -0,0 +1,41 @@
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="appframe-area"></div>
|
||||
<div class="layout-main-section">
|
||||
<div style="width: 48%; float: left;">
|
||||
<h4><a href="#!List/Web Page">Web Page</a></h4>
|
||||
<p class="help">Static (content) web page</p>
|
||||
<br>
|
||||
<h4><a href="#!List/Blog">Blog</a></h4>
|
||||
<p class="help">Weblog (blog) entry</p>
|
||||
</div>
|
||||
<div style="width: 48%; float: right;">
|
||||
<h4><a href="#!Form/Website Settings/Website Settings">Website Settings</a></h4>
|
||||
<p class="help">Setup of top navigation bar, footer and logo</p>
|
||||
<br>
|
||||
<h4><a href="#!Form/Style Settings/Style Settings">Style Settings</a></h4>
|
||||
<p class="help">Setup of fonts and background</p>
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
<hr>
|
||||
<h3>Reports</h3>
|
||||
<div class="reports-list"></div>
|
||||
</div>
|
||||
<div class="layout-side-section">
|
||||
<div class="psidebar">
|
||||
<div class="section">
|
||||
<p><b>Create website with static pages and blogs</b></p>
|
||||
<ul>
|
||||
<li>"Website Settings" - to setup header and footers.
|
||||
<li>"Web Page" - for static web page.
|
||||
<li>"Blog" - for blog entry.
|
||||
</ul>
|
||||
<p><b>Notes: </b></p>
|
||||
<ul>
|
||||
<li>All pages are accessible via `#` + page name appended to your url.
|
||||
<li>Product catalogue is updated from Item Master (set Show in Website = 'Yes', in
|
||||
Sales Settings).
|
||||
</ul> </div>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</div>
|
||||
20
website/page/website_home/website_home.js
Normal file
20
website/page/website_home/website_home.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// ERPNext - web based ERP (http://erpnext.com)
|
||||
// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
pscript['onload_website-home'] = function(wrapper) {
|
||||
wrapper.appframe = new wn.ui.AppFrame($(wrapper).find('.appframe-area'), 'Website');
|
||||
erpnext.module_page.setup_page('Website', wrapper);
|
||||
}
|
||||
28
website/page/website_home/website_home.txt
Normal file
28
website/page/website_home/website_home.txt
Normal file
@@ -0,0 +1,28 @@
|
||||
# Page, website-home
|
||||
[
|
||||
|
||||
# These values are common in all dictionaries
|
||||
{
|
||||
'creation': '2012-02-21 13:23:51',
|
||||
'docstatus': 0,
|
||||
'modified': '2012-02-21 13:23:51',
|
||||
'modified_by': u'Administrator',
|
||||
'owner': u'Administrator'
|
||||
},
|
||||
|
||||
# These values are common for all Page
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'module': u'Website',
|
||||
'name': '__common__',
|
||||
'page_name': u'website-home',
|
||||
'standard': u'Yes',
|
||||
'title': u'Website Home'
|
||||
},
|
||||
|
||||
# Page, website-home
|
||||
{
|
||||
'doctype': 'Page',
|
||||
'name': u'website-home'
|
||||
}
|
||||
]
|
||||
117
website/product.py
Normal file
117
website/product.py
Normal file
@@ -0,0 +1,117 @@
|
||||
from __future__ import unicode_literals
|
||||
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
|
||||
|
||||
# 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
|
||||
)"""
|
||||
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"""
|
||||
|
||||
# order by
|
||||
query += """
|
||||
order by item_name asc, name asc"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
return webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
@webnotes.whitelist(allow_guest=True)
|
||||
def get_product_category_list(args=None):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
query = """\
|
||||
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"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
|
||||
result = webnotes.conn.sql(query, args, 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):
|
||||
"""
|
||||
args = {
|
||||
'limit_start': 0,
|
||||
'limit_page_length': 5,
|
||||
'product_name': '',
|
||||
'product_group': '',
|
||||
}
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not args: args = webnotes.form_dict
|
||||
|
||||
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
|
||||
and name != %(product_name)s
|
||||
and item_group = %(product_group)s
|
||||
order by item_name"""
|
||||
|
||||
from webnotes.widgets.query_builder import add_limit_to_query
|
||||
query, args = add_limit_to_query(query, args)
|
||||
|
||||
result = webnotes.conn.sql(query, args, as_dict=1)
|
||||
|
||||
return result
|
||||
1
website/templates/__init__.py
Normal file
1
website/templates/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from __future__ import unicode_literals
|
||||
7
website/templates/css/blog.css
Normal file
7
website/templates/css/blog.css
Normal file
@@ -0,0 +1,7 @@
|
||||
<style>
|
||||
h2 > a, h2 > a:link, h2 > a:visited, h2 > a:active,
|
||||
h2 > a:hover, h2 > a:focus {
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
</style>
|
||||
9
website/templates/css/blog_page.css
Normal file
9
website/templates/css/blog_page.css
Normal file
@@ -0,0 +1,9 @@
|
||||
<style>
|
||||
.comment-title {
|
||||
color:#777;
|
||||
}
|
||||
|
||||
.comment-content {
|
||||
margin-left: 20px;
|
||||
}
|
||||
</style>
|
||||
10
website/templates/css/login.css
Normal file
10
website/templates/css/login.css
Normal file
@@ -0,0 +1,10 @@
|
||||
<style>
|
||||
#login_wrapper {
|
||||
width: 300px !important;
|
||||
margin: 20px auto;
|
||||
}
|
||||
|
||||
.login-banner {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
</style>
|
||||
34
website/templates/css/product_page.css
Normal file
34
website/templates/css/product_page.css
Normal file
@@ -0,0 +1,34 @@
|
||||
<style>
|
||||
.web-long-description {
|
||||
font-size: 18px;
|
||||
line-height: 200%;
|
||||
}
|
||||
.product-page-content {
|
||||
float: left;
|
||||
}
|
||||
/* product page image css */
|
||||
.product-page-content img {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
/* similar products listing */
|
||||
.similar-products .img-area img {
|
||||
max-width: 55px;
|
||||
max-height: 55px;
|
||||
}
|
||||
|
||||
.similar-products .img-area {
|
||||
float: left;
|
||||
width: 30%;
|
||||
margin-top: 0.3em;
|
||||
}
|
||||
|
||||
.similar-product-description {
|
||||
float: left;
|
||||
width: 70%;
|
||||
}
|
||||
|
||||
.similar-product-description span {
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
11
website/templates/css/products.css
Normal file
11
website/templates/css/products.css
Normal file
@@ -0,0 +1,11 @@
|
||||
<style>
|
||||
.img-area {
|
||||
float:left;
|
||||
width: 115px;
|
||||
}
|
||||
|
||||
.product-list-description {
|
||||
float:left;
|
||||
width: 400px;
|
||||
}
|
||||
</style>
|
||||
27
website/templates/html/base.html
Normal file
27
website/templates/html/base.html
Normal file
@@ -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="lib/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="app/images/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="app/images/favicon.ico" type="image/x-icon">
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% block header %}
|
||||
{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
{% block body %}
|
||||
{% endblock %}
|
||||
</body>
|
||||
56
website/templates/html/blog_page.html
Normal file
56
website/templates/html/blog_page.html
Normal file
@@ -0,0 +1,56 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/blog_page.js" %}
|
||||
{% include "js/blog_subscribe.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/blog_page.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="layout-wrapper layout-wrapper-background">
|
||||
<div class="web-content" id="blog-{{ name }}">
|
||||
|
||||
<div class="layout-main-section">
|
||||
|
||||
<h2>{{ title }}</h2>
|
||||
|
||||
<!-- begin blog content -->
|
||||
<div class="help">By {{ full_name }} on {{ updated }}</div>
|
||||
<br>
|
||||
{{ content_html }}
|
||||
<!-- end blog content -->
|
||||
|
||||
<hr>
|
||||
<h3>Comments</h3><br>
|
||||
<div class="blog-comments">
|
||||
|
||||
{% if not comment_list %}
|
||||
<div class="no-result help hide">
|
||||
<p>Be the first one to comment</p>
|
||||
<br />
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% include 'html/comment.html' %}
|
||||
</div>
|
||||
<button class="btn add-comment">Add Comment</button>
|
||||
</div>
|
||||
|
||||
<div class="layout-side-section">
|
||||
<p><a href="blog.html">All Blogs</a></p>
|
||||
<br />
|
||||
{% block blog_subscribe %}
|
||||
{% include "html/blog_subscribe.html" %}
|
||||
{% endblock %}
|
||||
<br />
|
||||
<h4>Recent Posts</h4>
|
||||
<div class="recent-posts" style="min-height: 100px;"></div>
|
||||
</div>
|
||||
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
9
website/templates/html/blog_subscribe.html
Normal file
9
website/templates/html/blog_subscribe.html
Normal file
@@ -0,0 +1,9 @@
|
||||
<h4>Subscribe</h4>
|
||||
<br>
|
||||
<p>
|
||||
<button class="btn btn-warning btn-blog-subscribe">Get Updates via Email</button>
|
||||
</p>
|
||||
<p>
|
||||
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">
|
||||
<a href="rss.xml" target="_blank">RSS Feed</a>
|
||||
</p>
|
||||
14
website/templates/html/comment.html
Normal file
14
website/templates/html/comment.html
Normal file
@@ -0,0 +1,14 @@
|
||||
{#
|
||||
this template generates comment rows for a blog
|
||||
it is to be included in the blog/blog.html template
|
||||
#}
|
||||
|
||||
{% for comment in comment_list %}
|
||||
<div class="comment-row">
|
||||
<div class="comment-title">
|
||||
{{ comment.comment_by_fullname }} - {{ comment.comment_date }}:
|
||||
</div>
|
||||
<p class="comment-content">{{ comment.comment }}</p>
|
||||
<hr>
|
||||
</div>
|
||||
{% endfor %}
|
||||
76
website/templates/html/outer.html
Normal file
76
website/templates/html/outer.html
Normal file
@@ -0,0 +1,76 @@
|
||||
{#
|
||||
requires, brand, top_bar_items, footer_items, copyright, content
|
||||
#}
|
||||
|
||||
{% extends "html/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 }}"
|
||||
{% if page.child_items %}
|
||||
class="dropdown"
|
||||
{% endif %}>
|
||||
<a href="{{ page.url or '#' }}"
|
||||
{% if page.child_items %}
|
||||
class="dropdown-toggle"
|
||||
onclick="return false;"
|
||||
data-toggle="dropdown"
|
||||
{% endif %}
|
||||
{{ page.target or ''}}>
|
||||
{{ page.label }}
|
||||
{% if page.child_items %}
|
||||
<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
{% for child in page.child_items %}
|
||||
<li data-label="{{ child.label }}">
|
||||
<a href="{{ child.url }}" {{ child.target or '' }}>
|
||||
{{ child.label }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
</a>
|
||||
{% endif %}
|
||||
</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.html">Login</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('.dropdown-toggle').dropdown()</script>
|
||||
</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>
|
||||
{% if copyright %}
|
||||
<div class="web-footer-copyright">© {{ copyright }}
|
||||
{% endif %}
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
{% endblock %}
|
||||
36
website/templates/html/page.html
Normal file
36
website/templates/html/page.html
Normal file
@@ -0,0 +1,36 @@
|
||||
{% extends "html/outer.html" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock %}
|
||||
|
||||
{% block header %}
|
||||
{{ super() }}
|
||||
<script>
|
||||
window.page_name = "{{ name }}";
|
||||
|
||||
$(document).bind('app_ready', function() {
|
||||
var _page = new wn.views.Page(window.page_name);
|
||||
|
||||
// page script
|
||||
{% block javascript %}
|
||||
{% endblock %}
|
||||
|
||||
// trigger onload
|
||||
_page.trigger('onload');
|
||||
|
||||
// activate page
|
||||
wn.container.change_to(window.page_name);
|
||||
});
|
||||
</script>
|
||||
|
||||
{% block css %}
|
||||
{% if insert_style %}
|
||||
|
||||
<style>{{ css }}</style>
|
||||
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{{ content }}
|
||||
{% endblock %}
|
||||
48
website/templates/html/product_page.html
Normal file
48
website/templates/html/product_page.html
Normal file
@@ -0,0 +1,48 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/product_page.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/product_page.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
29
website/templates/html/web_page.html
Normal file
29
website/templates/html/web_page.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% if insert_code %}
|
||||
{{ javascript }}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
43
website/templates/js/blog.js
Normal file
43
website/templates/js/blog.js
Normal file
@@ -0,0 +1,43 @@
|
||||
// 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),
|
||||
method: 'website.blog.get_blog_list',
|
||||
hide_refresh: true,
|
||||
no_toolbar: true,
|
||||
render_row: function(parent, data) {
|
||||
if(!data.comments) {
|
||||
data.comment_text = 'No comments yet.'
|
||||
} else if (data.comments===1) {
|
||||
data.comment_text = '1 comment.'
|
||||
} else {
|
||||
data.comment_text = data.comments + ' comments.'
|
||||
}
|
||||
|
||||
if(data.content && data.content.length==1000) {
|
||||
data.content += repl('... <a href="%(name)s.html">(read on)</a>', data);
|
||||
}
|
||||
parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\
|
||||
<div class="help">%(comment_text)s</div>\
|
||||
%(content)s<br /><br />', data);
|
||||
},
|
||||
page_length: 10
|
||||
});
|
||||
erpnext.blog_list.run();
|
||||
}
|
||||
181
website/templates/js/blog_page.js
Normal file
181
website/templates/js/blog_page.js
Normal file
@@ -0,0 +1,181 @@
|
||||
// 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
|
||||
erpnext.blog.render_recent_list(wrapper);
|
||||
|
||||
// unhide no-result if no comments found
|
||||
erpnext.blog.toggle_no_result(wrapper);
|
||||
|
||||
// bind add comment button to comment dialog
|
||||
erpnext.blog.make_comment_dialog(wrapper);
|
||||
|
||||
// hide add comment button after 50 comments
|
||||
erpnext.blog.toggle_add_comment_btn(wrapper);
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.blog.render_recent_list = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
wrapper.recent_list = new wn.ui.Listing({
|
||||
parent: $(wrapper).find('.recent-posts'),
|
||||
no_toolbar: true,
|
||||
method: 'website.blog.get_recent_blog_list',
|
||||
get_args: function() {
|
||||
return { name: '{{ name }}' }
|
||||
},
|
||||
hide_refresh: true,
|
||||
render_row: function(parent, data) {
|
||||
if(data.content && data.content.length>=100) data.content += '...';
|
||||
parent.innerHTML = repl('<div style="font-size: 80%">\
|
||||
<a href="%(page_name)s.html">%(title)s</a>\
|
||||
<div class="comment">%(content)s</div><br></div>', data);
|
||||
|
||||
// adjust page height depending on sidebar height
|
||||
erpnext.blog.adjust_page_height(wrapper);
|
||||
},
|
||||
page_length: 5,
|
||||
});
|
||||
wrapper.recent_list.run();
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_no_result = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
var $blog_comments = $(wrapper).find('.blog-comments');
|
||||
var $comment_rows = $blog_comments.find('.comment-row');
|
||||
var $no_result = $blog_comments.find('.no-result');
|
||||
|
||||
if ($comment_rows.length == 0) {
|
||||
$no_result.removeClass('hide');
|
||||
} else {
|
||||
$no_result.addClass('hide');
|
||||
}
|
||||
}
|
||||
|
||||
erpnext.blog.make_comment_dialog = function(wrapper) {
|
||||
if (!wrapper) { wrapper = erpnext.blog.wrapper; }
|
||||
if (!wrapper) { return; }
|
||||
|
||||
var $comment_btn = $(wrapper).find('button.add-comment');
|
||||
|
||||
$comment_btn.click(function() {
|
||||
if(!erpnext.blog.comment_dialog) {
|
||||
var 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_comment', label: 'Post Comment',
|
||||
fieldtype: 'Button'
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
erpnext.blog.comment_dialog = d;
|
||||
}
|
||||
|
||||
erpnext.blog.comment_dialog.fields_dict.post_comment
|
||||
.input.onclick = function() {
|
||||
erpnext.blog.add_comment(wrapper);
|
||||
}
|
||||
|
||||
erpnext.blog.comment_dialog.show();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
erpnext.blog.add_comment = function(wrapper) {
|
||||
var args = erpnext.blog.comment_dialog.get_values();
|
||||
|
||||
if(!args) return;
|
||||
|
||||
args.comment_doctype = 'Blog';
|
||||
args.comment_docname = '{{ name }}';
|
||||
args.page_name = '{{ page_name }}';
|
||||
|
||||
wn.call({
|
||||
method: 'website.blog.add_comment',
|
||||
args: args,
|
||||
btn: this,
|
||||
callback: function(r) {
|
||||
if(!r.exc) {
|
||||
erpnext.blog.add_comment_to_page(wrapper, r.message);
|
||||
erpnext.blog.comment_dialog.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
erpnext.blog.add_comment_to_page = function(wrapper, comment) {
|
||||
$blog_comments = $(wrapper).find('.blog-comments');
|
||||
$comment_rows = $blog_comments.find('.comment-row');
|
||||
|
||||
if ($comment_rows.length) {
|
||||
$blog_comments.append(comment);
|
||||
} else {
|
||||
$blog_comments.append(comment);
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_no_result(wrapper);
|
||||
erpnext.blog.toggle_add_comment_btn(wrapper);
|
||||
}
|
||||
|
||||
erpnext.blog.toggle_add_comment_btn = function(wrapper) {
|
||||
var $wrapper = $(wrapper);
|
||||
if ($wrapper.find('.blog-comments .comment-row').length > 50) {
|
||||
var $comment_btn = $wrapper.find('button.add-comment');
|
||||
$comment_btn.addClass('hide');
|
||||
|
||||
// show comments are close
|
||||
$wrapper.find('.blog-comments').append("\
|
||||
<div class=\"help\"> \
|
||||
<p>Comments Closed</p> \
|
||||
<br /> \
|
||||
</div>");
|
||||
}
|
||||
}
|
||||
33
website/templates/js/blog_subscribe.js
Normal file
33
website/templates/js/blog_subscribe.js
Normal file
@@ -0,0 +1,33 @@
|
||||
wn.provide('erpnext.blog');
|
||||
|
||||
(function() {
|
||||
$('body').on('click', '.btn-blog-subscribe', function() {
|
||||
var d = new wn.ui.Dialog({
|
||||
title: "Get Blog Updates via Email",
|
||||
fields: [
|
||||
{label: "Your Name", fieldtype:"Data", reqd:1},
|
||||
{label: "Your Email Address", fieldtype:"Data", reqd:1
|
||||
,description: "You can unsubscribe anytime."},
|
||||
{label: "Subscribe", fieldtype:"Button"}
|
||||
]
|
||||
});
|
||||
$(d.fields_dict.subscribe.input).click(function() {
|
||||
var args = d.get_values();
|
||||
if(!args) return;
|
||||
wn.call({
|
||||
method: 'website.blog.add_subscriber',
|
||||
args: args,
|
||||
callback: function(r) {
|
||||
if(r.exc) {
|
||||
msgprint('Opps there seems to be some error, Please check back after some time.');
|
||||
} else {
|
||||
msgprint('Thanks for subscribing!');
|
||||
}
|
||||
d.hide();
|
||||
},
|
||||
btn: this
|
||||
})
|
||||
})
|
||||
d.show()
|
||||
})
|
||||
})()
|
||||
92
website/templates/js/login.js
Normal file
92
website/templates/js/login.js
Normal file
@@ -0,0 +1,92 @@
|
||||
// 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.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();
|
||||
$('#login_message').empty();
|
||||
|
||||
$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();
|
||||
}
|
||||
18
website/templates/js/product_category.js
Normal file
18
website/templates/js/product_category.js
Normal file
@@ -0,0 +1,18 @@
|
||||
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();
|
||||
}
|
||||
92
website/templates/js/product_page.js
Normal file
92
website/templates/js/product_page.js
Normal file
@@ -0,0 +1,92 @@
|
||||
// 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/>.
|
||||
|
||||
{% include "js/product_category.js" %}
|
||||
|
||||
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();
|
||||
}
|
||||
106
website/templates/js/products.js
Normal file
106
website/templates/js/products.js
Normal file
@@ -0,0 +1,106 @@
|
||||
// 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
|
||||
|
||||
{% include "js/product_category.js" %}
|
||||
|
||||
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};
|
||||
}
|
||||
12
website/templates/pages/404.html
Normal file
12
website/templates/pages/404.html
Normal file
@@ -0,0 +1,12 @@
|
||||
{% extends "html/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 %}
|
||||
34
website/templates/pages/blog.html
Normal file
34
website/templates/pages/blog.html
Normal file
@@ -0,0 +1,34 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/blog.js" %}
|
||||
{% include "js/blog_subscribe.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/blog.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}Blog{% 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">
|
||||
{% block blog_subscribe %}
|
||||
{% include "html/blog_subscribe.html" %}
|
||||
{% endblock %}
|
||||
</div>
|
||||
<div style="clear: both"></div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
1
website/templates/pages/index.html
Normal file
1
website/templates/pages/index.html
Normal file
@@ -0,0 +1 @@
|
||||
{% extends "html/web_page.html" %}
|
||||
52
website/templates/pages/login.html
Normal file
52
website/templates/pages/login.html
Normal file
@@ -0,0 +1,52 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/login.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/login.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
37
website/templates/pages/products.html
Normal file
37
website/templates/pages/products.html
Normal file
@@ -0,0 +1,37 @@
|
||||
{% extends "html/page.html" %}
|
||||
|
||||
{% block javascript %}
|
||||
{% include "js/products.js" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block css %}
|
||||
{% include "css/products.css" %}
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
11
website/templates/pages/unsubscribed.html
Normal file
11
website/templates/pages/unsubscribed.html
Normal file
@@ -0,0 +1,11 @@
|
||||
{% extends "html/outer.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="content">
|
||||
<div class="layout-wrapper layout-main">
|
||||
<h3>Unsubscribed</h3>
|
||||
<br>
|
||||
<p><b>{{ webnotes.unsubscribed_email }}</b> has been unsubscribed.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
78
website/utils.py
Normal file
78
website/utils.py
Normal file
@@ -0,0 +1,78 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.model.doc import Document
|
||||
|
||||
def scrub_page_name(page_name):
|
||||
if page_name.endswith('.html'):
|
||||
page_name = page_name[:-5]
|
||||
|
||||
return page_name
|
||||
|
||||
def make_template(doc, path, convert_fields = ['main_section', 'side_section']):
|
||||
"""make template"""
|
||||
import os, jinja2
|
||||
|
||||
markdown(doc, convert_fields)
|
||||
|
||||
# write template
|
||||
with open(path, 'r') as f:
|
||||
temp = jinja2.Template(f.read())
|
||||
|
||||
return temp.render(doc = doc.fields)
|
||||
|
||||
def page_name(title):
|
||||
"""make page name from title"""
|
||||
import re
|
||||
name = title.lower()
|
||||
name = re.sub('[~!@#$%^&*()<>,."\']', '', name)
|
||||
return '-'.join(name.split()[:4])
|
||||
|
||||
def render(page_name):
|
||||
"""render html page"""
|
||||
import webnotes
|
||||
try:
|
||||
if page_name:
|
||||
html = get_html(page_name)
|
||||
else:
|
||||
html = get_html('index')
|
||||
except Exception, e:
|
||||
html = get_html('404')
|
||||
|
||||
from webnotes.handler import eprint, print_zip
|
||||
eprint("Content-Type: text/html")
|
||||
print_zip(html)
|
||||
|
||||
def get_html(page_name):
|
||||
"""get page html"""
|
||||
page_name = scrub_page_name(page_name)
|
||||
comments = get_comments(page_name)
|
||||
|
||||
import website.web_cache
|
||||
html = website.web_cache.get_html(page_name, comments)
|
||||
return html
|
||||
|
||||
def get_comments(page_name):
|
||||
import webnotes
|
||||
|
||||
if page_name == '404':
|
||||
comments = """error: %s""" % webnotes.getTraceback()
|
||||
else:
|
||||
comments = """page: %s""" % page_name
|
||||
|
||||
return comments
|
||||
266
website/web_cache.py
Normal file
266
website/web_cache.py
Normal file
@@ -0,0 +1,266 @@
|
||||
# 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/>.
|
||||
|
||||
# html generation functions
|
||||
|
||||
from __future__ import unicode_literals
|
||||
template_map = {
|
||||
'Web Page': 'html/web_page.html',
|
||||
'Blog': 'html/blog_page.html',
|
||||
'Item': 'html/product_page.html',
|
||||
}
|
||||
|
||||
def get_html(page_name, comments=''):
|
||||
import conf
|
||||
|
||||
html = ''
|
||||
|
||||
# load from cache, if auto cache clear is falsy
|
||||
if not (hasattr(conf, 'auto_cache_clear') and conf.auto_cache_clear or 0):
|
||||
html = load_from_cache(page_name)
|
||||
|
||||
if not html:
|
||||
html = load_into_cache(page_name)
|
||||
comments += "\n\npage load status: fresh"
|
||||
|
||||
# insert comments
|
||||
import webnotes.utils
|
||||
html += """\n<!-- %s -->""" % webnotes.utils.cstr(comments)
|
||||
|
||||
return html
|
||||
|
||||
def load_from_cache(page_name):
|
||||
import webnotes
|
||||
|
||||
result = search_cache(page_name)
|
||||
|
||||
if not result:
|
||||
if page_name in get_predefined_pages():
|
||||
# if a predefined page doesn't exist, load it into cache
|
||||
return None
|
||||
else:
|
||||
# if page doesn't exist, raise exception
|
||||
raise Exception, "Page %s not found" % page_name
|
||||
|
||||
return result[0][0]
|
||||
|
||||
def load_into_cache(page_name):
|
||||
args = prepare_args(page_name)
|
||||
|
||||
html = build_html(args)
|
||||
|
||||
# create cache entry for predefined pages, if not exists
|
||||
if page_name in get_predefined_pages():
|
||||
create_cache(page_name)
|
||||
|
||||
import webnotes
|
||||
webnotes.conn.begin()
|
||||
webnotes.conn.set_value('Web Cache', page_name, 'html', html)
|
||||
webnotes.conn.commit()
|
||||
|
||||
return html
|
||||
|
||||
def get_predefined_pages():
|
||||
"""
|
||||
gets a list of predefined pages
|
||||
they do not exist in `tabWeb Page`
|
||||
"""
|
||||
import os
|
||||
import conf
|
||||
import website.utils
|
||||
|
||||
pages_path = os.path.join(os.path.dirname(conf.__file__), 'app', 'website', 'templates', 'pages')
|
||||
|
||||
page_list = []
|
||||
|
||||
for page in os.listdir(pages_path):
|
||||
page_list.append(website.utils.scrub_page_name(page))
|
||||
|
||||
return page_list
|
||||
|
||||
def prepare_args(page_name):
|
||||
import webnotes
|
||||
if page_name == 'index':
|
||||
page_name = get_home_page()
|
||||
|
||||
if page_name in get_predefined_pages():
|
||||
args = {
|
||||
'template': 'pages/%s.html' % page_name,
|
||||
'name': page_name,
|
||||
'webnotes': webnotes
|
||||
}
|
||||
else:
|
||||
args = get_doc_fields(page_name)
|
||||
|
||||
args.update(get_outer_env())
|
||||
|
||||
return args
|
||||
|
||||
def get_home_page():
|
||||
import webnotes
|
||||
doc_name = webnotes.conn.get_value('Website Settings', None, 'home_page')
|
||||
if doc_name:
|
||||
page_name = webnotes.conn.get_value('Web Page', doc_name, 'page_name')
|
||||
else:
|
||||
page_name = 'login'
|
||||
|
||||
return page_name
|
||||
|
||||
def get_doc_fields(page_name):
|
||||
import webnotes
|
||||
doc_type, doc_name = webnotes.conn.get_value('Web Cache', page_name, ['doc_type', 'doc_name'])
|
||||
|
||||
import webnotes.model.code
|
||||
obj = webnotes.model.code.get_obj(doc_type, doc_name)
|
||||
|
||||
if hasattr(obj, 'prepare_template_args'):
|
||||
obj.prepare_template_args()
|
||||
|
||||
args = obj.doc.fields
|
||||
args['template'] = template_map[doc_type]
|
||||
|
||||
return args
|
||||
|
||||
def get_outer_env():
|
||||
"""
|
||||
env dict for outer template
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
all_top_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)
|
||||
|
||||
top_items = [d for d in all_top_items if not d['parent_label']]
|
||||
|
||||
# attach child items to top bar
|
||||
for d in all_top_items:
|
||||
if d['parent_label']:
|
||||
for t in top_items:
|
||||
if t['label']==d['parent_label']:
|
||||
if not 'child_items' in t:
|
||||
t['child_items'] = []
|
||||
t['child_items'].append(d)
|
||||
break
|
||||
|
||||
return {
|
||||
'top_bar_items': top_items,
|
||||
|
||||
'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') or 'ERPNext',
|
||||
'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'),
|
||||
'favicon': webnotes.conn.get_value('Website Settings', None, 'favicon')
|
||||
}
|
||||
|
||||
def build_html(args):
|
||||
"""
|
||||
build html using jinja2 templates
|
||||
"""
|
||||
import os
|
||||
import conf
|
||||
templates_path = os.path.join(os.path.dirname(conf.__file__), 'app', 'website', 'templates')
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
jenv = Environment(loader = FileSystemLoader(templates_path))
|
||||
html = jenv.get_template(args['template']).render(args)
|
||||
return html
|
||||
|
||||
# cache management
|
||||
def search_cache(page_name):
|
||||
if not page_name: return ()
|
||||
import webnotes
|
||||
return webnotes.conn.sql("""\
|
||||
select html, doc_type, doc_name
|
||||
from `tabWeb Cache`
|
||||
where name = %s""", page_name)
|
||||
|
||||
def create_cache(page_name, doc_type=None, doc_name=None):
|
||||
# check if a record already exists
|
||||
result = search_cache(page_name)
|
||||
if result: return
|
||||
|
||||
# create a Web Cache record
|
||||
import webnotes.model.doc
|
||||
d = webnotes.model.doc.Document('Web Cache')
|
||||
d.name = page_name
|
||||
d.doc_type = doc_type
|
||||
d.doc_name = doc_name
|
||||
d.html = None
|
||||
d.save()
|
||||
|
||||
def clear_cache(page_name, doc_type=None, doc_name=None):
|
||||
"""
|
||||
* if no page name, clear whole cache
|
||||
* if page_name, doc_type and doc_name match, clear cache's copy
|
||||
* else, raise exception that such a page already exists
|
||||
"""
|
||||
import webnotes
|
||||
|
||||
if not page_name:
|
||||
webnotes.conn.sql("""update `tabWeb Cache` set html = ''""")
|
||||
return
|
||||
|
||||
result = search_cache(page_name)
|
||||
|
||||
if not doc_type or (result and result[0][1] == doc_type and result[0][2] == doc_name):
|
||||
webnotes.conn.set_value('Web Cache', page_name, 'html', '')
|
||||
else:
|
||||
webnotes.msgprint("""Page with name "%s" already exists as a %s.
|
||||
Please save it with another name.""" % (page_name, result[0][1]),
|
||||
raise_exception=1)
|
||||
|
||||
def delete_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 refresh_cache(build=None):
|
||||
"""delete and re-create web cache entries"""
|
||||
import webnotes
|
||||
|
||||
# webnotes.conn.sql("delete from `tabWeb Cache`")
|
||||
|
||||
clear_cache(None)
|
||||
|
||||
query_map = {
|
||||
'Web Page': """select page_name, name from `tabWeb Page` where docstatus=0""",
|
||||
'Blog': """\
|
||||
select page_name, name from `tabBlog`
|
||||
where docstatus = 0 and ifnull(published, 0) = 1""",
|
||||
'Item': """\
|
||||
select page_name, name from `tabItem`
|
||||
where docstatus = 0 and ifnull(show_in_website, 0) = 1""",
|
||||
}
|
||||
|
||||
for dt in query_map:
|
||||
if build and dt in build:
|
||||
for result in webnotes.conn.sql(query_map[dt], as_dict=1):
|
||||
create_cache(result['page_name'], dt, result['name'])
|
||||
load_into_cache(result['page_name'])
|
||||
|
||||
for page_name in get_predefined_pages():
|
||||
create_cache(page_name, None, None)
|
||||
if build: load_into_cache(page_name)
|
||||
82
website/web_page.py
Normal file
82
website/web_page.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# 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/>.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
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 of %s and save again."""
|
||||
% (self.doctype, self.doc.name), 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.create_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
website.web_cache.clear_cache(self.doc.page_name, self.doc.doctype, self.doc.name)
|
||||
|
||||
def delete_web_cache(self, page_name):
|
||||
"""delete entry of page name from Web Cache"""
|
||||
website.web_cache.delete_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"])
|
||||
Reference in New Issue
Block a user