added home template

This commit is contained in:
Rushabh Mehta 2012-01-25 15:06:28 +05:30
parent 9c7a01ade9
commit 4b1fe0528a
10 changed files with 116 additions and 28 deletions

0
blank.html Normal file
View File

View File

@ -2,6 +2,8 @@
import webnotes
def execute():
cleanup_file_data()
return
update_patch_log()
from webnotes.modules import reload_doc
reload_doc('website', 'Module Def', 'Website')
@ -11,6 +13,11 @@ def execute():
reload_doc('website', 'doctype', 'top_bar_item')
reload_doc('website', 'page', 'home')
def cleanup_file_data():
webnotes.conn.commit()
webnotes.conn.sql("""alter table `tabFile Data` drop column blob_content""")
webnotes.conn.begin()
def update_patch_log():
webnotes.conn.commit()
webnotes.conn.sql("""alter table __PatchLog engine=InnoDB""")

View File

@ -50,4 +50,4 @@ def get_letter_heads():
"""load letter heads with startup"""
import webnotes
ret = webnotes.conn.sql("select name, content from `tabLetter Head` where ifnull(disabled,0)=0")
dict(ret)
return dict(ret)

View File

@ -6,4 +6,16 @@
header .topbar .container {
width: 900px;
margin: auto;
}
.web-main-section {
width: 65%;
float: left;
margin-bottom: 20px;
}
.web-side-section {
width: 30%;
float: right;
margin-bottom: 20px;
}

View File

@ -0,0 +1,26 @@
"""
generate home html
"""
class DocType:
def __init__(self, d, dl):
self.doc, self.doclist = d, dl
def on_update(self):
"""make home html"""
import os, jinja2, markdown2
import webnotes
# markdown
self.doc.main_section_html = markdown2.markdown(self.doc.main_section or '', \
extras=["wiki-tables"])
self.doc.side_section_html = markdown2.markdown(self.doc.side_section or '', \
extras=["wiki-tables"])
# write template
with open(os.path.join(os.path.dirname(__file__), 'template.html'), 'r') as f:
temp = jinja2.Template(f.read())
html = temp.render(doc = self.doc.fields)
webnotes.conn.set_value('Page', 'Home', 'content', html)

View File

@ -5,31 +5,29 @@
{
'creation': '2012-01-24 15:56:06',
'docstatus': 0,
'modified': '2012-01-24 15:56:06',
'modified': '2012-01-25 13:31:56',
'modified_by': 'Administrator',
'owner': 'Administrator'
},
# These values are common for all DocType
{
'_last_update': '1327476129',
'allow_attach': 1,
'colour': 'White:FFF',
'doctype': 'DocType',
'issingle': 1,
'max_attachments': 5,
'module': 'Website',
'name': '__common__',
'section_style': 'Simple',
'show_in_menu': 0,
'version': 1
'version': 4
},
# These values are common for all DocField
{
'colour': 'White:FFF',
'description': 'HTML that will appear on the top part of the home page. Usually should contain a headline and image.',
'doctype': 'DocField',
'fieldname': 'banner_html',
'fieldtype': 'Code',
'label': 'Banner HTML',
'name': '__common__',
'parent': 'Home Settings',
'parentfield': 'fields',
@ -70,6 +68,51 @@
# DocField
{
'doctype': 'DocField'
'colour': 'White:FFF',
'description': 'HTML that will appear on the top part of the home page. For no headline, leave blank',
'doctype': 'DocField',
'fieldname': 'headline',
'fieldtype': 'Text',
'label': 'Headline'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'banner',
'fieldtype': 'Select',
'label': 'Banner',
'options': 'attach_files:'
},
# DocField
{
'colour': 'White:FFF',
'description': 'For formatting, use \n<a href="http://warpedvisions.org/projects/markdown-cheat-sheet/" \ntarget = "_blank">markdown</a>',
'doctype': 'DocField',
'fieldname': 'main_section',
'fieldtype': 'Code',
'label': 'Main Section'
},
# DocField
{
'colour': 'White:FFF',
'description': 'For formatting, use \n<a href="http://warpedvisions.org/projects/markdown-cheat-sheet/" \ntarget = "_blank">markdown</a>',
'doctype': 'DocField',
'fieldname': 'side_section',
'fieldtype': 'Code',
'label': 'Side Section'
},
# DocField
{
'doctype': 'DocField',
'fieldname': 'file_list',
'fieldtype': 'Text',
'hidden': 1,
'label': 'File List',
'no_copy': 1,
'print_hide': 1
}
]

View File

@ -0,0 +1,17 @@
<div class="layout_wrapper">
<div id="content-home">
{% if doc.headline %}
<h1>{{ doc.headline }}</h1>
{% endif %}
{% if doc.banner %}
<img src="files/{{ doc.banner }}" style="width: 870px; margin-bottom: 20px" />
{% endif %}
<div class="web-main-section">
{{ doc.main_section_html }}
</div>
<div class="web-side-section">
{{ doc.side_section_html }}
</div>
<div style="clear: both"></div>
</div>
</div>

View File

@ -1,17 +0,0 @@
#!python
from webnotes.model.doc import getsingle
from jinja2 import Template
temp = Template("""
<div class="layout_wrapper">
<div id="content-home">
{{ home_settings.banner_html }}
</div>
</div>
""")
out = {
"content": temp.render(home_settings = getsingle('Home Settings'))
}

View File

@ -3,7 +3,7 @@
<meta charset="utf-8">
<title>ERPNext</title>
<meta name="author" content="">
<script type="text/javascript">window._version_number="192";
<script type="text/javascript">window._version_number="201";
/*
* lib/js/wn/class.js

View File

@ -1 +1 @@
192
201