added patch

This commit is contained in:
Rushabh Mehta 2012-06-19 14:15:13 +05:30
parent 96bf0b7f53
commit 40182bada3
3 changed files with 45 additions and 16 deletions

View File

@ -0,0 +1,11 @@
def execute():
import webnotes
from webnotes.model.doclist import DocList
import webnotes.model.sync
# sync web page doctype
webnotes.model.sync.sync('website', 'web_page')
# save all web pages to create content
for p in webnotes.conn.sql("""select name from `tabWeb Page` where docstatus=0"""):
DocList('Web Page', p[0]).save()

View File

@ -1,4 +1,7 @@
{% extends "index.html" %}
{% extends "outer.html" %}
{% block title %}{{ title }}{% endblock %}
{% block content %}
<div class="layout-wrapper layout-wrapper-background">
@ -28,7 +31,9 @@
</div>
<script>
wrapper.blog_list = new wn.ui.Listing({
// if not a specific blog, show listing
erpnext.blog_list = new wn.ui.Listing({
parent: $(wrapper).find('#blog-list').get(0),
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
@ -49,5 +54,5 @@ wrapper.blog_list = new wn.ui.Listing({
},
page_length: 10
});
wrapper.blog_list.run();
erpnext.blog_list.run();
</script>

View File

@ -17,6 +17,9 @@ sys.path.append(conf.modules_path)
def get_outer_env():
"""env for outer (cache this)"""
# TODO: Cache this in cache item
import webnotes
return {
'top_bar_items': webnotes.conn.sql("""select * from `tabTop Bar Item`
@ -31,7 +34,7 @@ def get_outer_env():
'copyright': webnotes.conn.get_value('Website Settings', None, 'copyright'),
}
def get_page_by_short_name(page_name):
def get_web_page_name(page_name):
"""get page by shortname"""
import webnotes
return webnotes.conn.sql("""select name from `tabWeb Page` where page_name=%s""", page_name)[0][0]
@ -47,21 +50,31 @@ def get_html():
for key in webnotes.form.keys():
webnotes.form_dict[key] = webnotes.form.getvalue(key)
webnotes.connect()
if 'page' in webnotes.form_dict:
page_name = webnotes.form_dict['page']
if page_name.endswith('.html'):
page_name = page_name[:-5]
# Get web page
try:
if 'page' in webnotes.form_dict:
page_name = webnotes.form_dict['page']
if page_name.endswith('.html'):
page_name = page_name[:-5]
if page_name.startswith('blog'):
pass
# page_name =
else:
page_name = get_web_page_name(page_name)
else:
from webnotes.cms import get_home_page
page_name = get_home_page('Guest')
#try:
page_name = get_page_by_short_name(page_name)
page = Document('Web Page', page_name)
page.fields.update(get_outer_env())
return jenv.get_template('page.html').render(page.fields)
#except Exception, e:
# return jenv.get_template('404.html').render(get_outer_env())
else:
return jenv.get_template('404.html').render(get_outer_env())
return jenv.get_template('page.html').render(page.fields) + \
('\n<!-- page: %s -->' % page_name)
except Exception, e:
return jenv.get_template('404.html').render(get_outer_env()) + \
('\n<!-- error: %s -->' % webnotes.getTraceback())
if __name__=="__main__":
print "Content-Type: text/html"