website updates

This commit is contained in:
Rushabh Mehta
2012-04-26 19:01:35 +05:30
parent 44279f87b4
commit 702473d65e
17 changed files with 515 additions and 95 deletions

View File

@@ -13,7 +13,6 @@ span, div, td, input, textarea, button, select {
}
body {
background: url(../images/redbeech.jpg) repeat;
color: #616161;
}

View File

@@ -170,7 +170,7 @@ erpnext.startup.set_periodic_updates = function() {
}
erpnext.set_user_background = function(src) {
set_style(repl('body { background: url("files/%(src)s") repeat;}', {src:src}))
set_style(repl('#body_div { background: url("files/%(src)s") repeat;}', {src:src}))
}
// start

View File

@@ -1,9 +1,10 @@
div#body_div, header .container, .content, #opened-page-selector, footer {
header .container, .content {
width: 900px;
}
div#body_div {
margin-top: 90px;
padding-top: 90px;
min-height: 400px;
}
p, li {
@@ -62,19 +63,23 @@ pre {
background-color: #444;
}
footer {
color: #777;
background-color: #eee;
box-shadow: inset 0 10px 10px rgba(0,0,0,0.3), inset 0 3px 3px rgba(0,0,0,0.3);
border-top: 1px solid #555;
padding-top: 10px;
text-align: center;
}
.web-footer {
color: inherit;
text-align: center;
margin: 10px;
padding: 10px;
line-height: 1.7;
}
.web-footer div, .web-footer a {
font-size: 14px;
font-size: 12px;
}
.web-footer-menu {
@@ -93,10 +98,20 @@ footer {
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 {

View File

@@ -32,9 +32,11 @@ class DocType():
self.doc.name = website.utils.page_name(self.doc.title)
def validate(self):
"""write/update 'Page' with the blog"""
"""write/update 'Page' with the blog"""
if self.doc.page_name:
webnotes.conn.sql("""delete from tabPage where name=%s""", self.doc.page_name)
p = website.utils.add_page(self.doc.title)
self.doc.name = p.name
from jinja2 import Template
import markdown2
@@ -54,11 +56,11 @@ class DocType():
p.save()
website.utils.add_guest_access_to_page(p.name)
self.doc.page_name = p.name
# cleanup
for f in ['content_html', 'full_name', 'updated']:
if f in self.doc.fields:
del self.doc.fields[f]
del self.doc.fields[f]

View File

@@ -3,9 +3,9 @@
# These values are common in all dictionaries
{
'creation': '2012-03-27 14:36:47',
'creation': '2012-04-02 16:02:43',
'docstatus': 0,
'modified': '2012-03-27 14:36:47',
'modified': '2012-04-26 16:58:27',
'modified_by': u'Administrator',
'owner': u'Administrator'
},
@@ -21,7 +21,7 @@
'name': '__common__',
'section_style': u'Simple',
'show_in_menu': 0,
'version': 3
'version': 5
},
# These values are common for all DocField
@@ -35,15 +35,12 @@
# These values are common for all DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'name': '__common__',
'parent': u'Blog',
'parentfield': u'permissions',
'parenttype': u'DocType',
'permlevel': 0,
'read': 1,
'write': 1
'read': 1
},
# DocType, Blog
@@ -54,14 +51,27 @@
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'role': u'Website Manager'
'permlevel': 0,
'role': u'Website Manager',
'write': 1
},
# DocPerm
{
'create': 1,
'doctype': u'DocPerm',
'permlevel': 0,
'role': u'Blogger',
'write': 1
},
# DocPerm
{
'doctype': u'DocPerm',
'role': u'Blogger'
'permlevel': 1,
'role': u'All'
},
# DocField
@@ -70,7 +80,8 @@
'fieldname': u'title',
'fieldtype': u'Data',
'label': u'Title',
'permlevel': 0
'permlevel': 0,
'reqd': 1
},
# DocField
@@ -88,7 +99,8 @@
'fieldname': u'content',
'fieldtype': u'Code',
'label': u'Content',
'permlevel': 0
'permlevel': 0,
'reqd': 0
},
# DocField
@@ -96,10 +108,19 @@
'doctype': u'DocField',
'fieldname': u'content_html',
'fieldtype': u'Text',
'label': u'Preview',
'label': u'Content HTML',
'permlevel': 1
},
# DocField
{
'doctype': u'DocField',
'fieldname': u'page_name',
'fieldtype': u'Data',
'label': u'Page Name',
'permlevel': 0
},
# DocField
{
'doctype': u'DocField',

View File

@@ -18,32 +18,28 @@
pscript['onload_{{ doc.name }}'] = function(wrapper) {
// sidebar
var side = $(wrapper).find('.web-side-section')
.append('<h4>Recent Posts</h4>').get(0);
wrapper.recent_list = new wn.ui.Listing({
parent: side,
parent: $(wrapper).find('.recent-posts'),
no_toolbar: true,
query: 'select name, title, left(content, 100) as content from tabBlog\
where ifnull(published,1)=1',
where ifnull(published,0)=1 and name!="{{ doc.name }}" order by modified desc',
hide_refresh: true,
render_row: function(parent, data) {
if(data.content.length==100) data.content += '...';
console.log(data);
if(data.content && data.content.length==100) data.content += '...';
parent.innerHTML = repl('<a href="#!%(name)s">%(title)s</a>\
<div class="comment">%(content)s</div><br>', data);
},
page_length: 5
page_length: 5,
});
wrapper.recent_list.run();
// comments
$(wrapper).find('.web-main-section').append('<hr><h3>Comments</h3>');
wrapper.comment_list = new wn.ui.Listing({
parent: $(wrapper).find('.web-main-section').get(0),
parent: $(wrapper).find('.blog-comments').get(0),
no_toolbar: true,
query: 'select comment, comment_by_fullname, modified\
from `tabComment` where comment_doctype="Page"\
and comment_docname="{{ doc.name }}"',
and comment_docname="{{ doc.name }}" order by modified desc',
no_result_message: 'Be the first one to comment',
render_row: function(parent, data) {
data.comment_date = prettyDate(data.modified);
@@ -57,7 +53,7 @@ pscript['onload_{{ doc.name }}'] = function(wrapper) {
wrapper.comment_list.run();
// add comment
$(wrapper).find('.web-main-section').append('<br><button class="btn add-comment">\
$(wrapper).find('.layout-main-section').append('<br><button class="btn add-comment">\
Add Comment</button>');
$(wrapper).find('button.add-comment').click(function(){
d = new wn.widgets.Dialog({

View File

@@ -1,14 +1,18 @@
<div class="layout-wrapper layout-wrapper-background">
<div class="web-content" id="blog-{{ doc.name }}">
<div class="layout-main-section">
<h1>Blog</h1>
<h3>{{ doc.title }}</h3>
<h2>{{ doc.title }}</h2>
<div class="help">By {{ doc.full_name }} on {{ doc.updated }}</div>
<br>
{{ doc.content_html }}
<hr><h3>Comments</h3>
<br>
<div class="blog-comments"></div>
</div>
<div class="layout-side-section">
<p><a href="#!blog">All Blogs</a></p>
<h4>Recent Posts</h4>
<div class="recent-posts" style="min-height: 100px;"></div>
<h4>Subscribe</h4>
<p>
<img src="images/feed.png" style="margin-right: 4px; margin-bottom: -4px">

View File

@@ -1,4 +1,4 @@
body {
#body_div {
{% if doc.background_image %}
background: url("files/{{ doc.background_image }}") repeat;
{% elif doc.background_color %}

View File

@@ -28,6 +28,3 @@
<div style="clear: both"></div>
</div>
</div>
<div class="web-page-status small">
Last Modified: {{ doc.updated }} <a href="#contact">Feedback</a>
</div>

View File

@@ -24,10 +24,10 @@ $.extend(cur_frm.cscript, {
refresh: function(doc) {
cur_frm.cscript.layout(doc);
},
insert_style: function() {
insert_style: function(doc) {
cur_frm.cscript.layout(doc);
},
insert_code: function() {
insert_code: function(doc) {
cur_frm.cscript.layout(doc);
}
})

View File

@@ -91,8 +91,7 @@ erpnext.Footer = Class.extend({
init: function() {
$('footer').html(repl('<div class="web-footer">\
<div class="web-footer-menu"><ul></ul></div>\
<div class="web-footer-address">%(address)s</div>\
<div class="web-footer-copyright">&copy; %(copyright)s</div>\
<div class="web-footer-copyright">&copy; %(copyright)s | %(address)s</div>\
<div class="web-footer-powered">Powered by \
<a href="https://erpnext.com">erpnext.com</a></div>\
</div>', wn.boot.website_settings));

View File

@@ -3,6 +3,7 @@
<div class="layout-main-section">
<h1>Blog</h1>
<br>
<div id="blog-list"></div>
</div>
<div class="layout-side-section">
<!-- for later

View File

@@ -17,18 +17,22 @@
pscript.onload_blog = function(wrapper) {
wrapper.blog_list = new wn.ui.Listing({
parent: $(wrapper).find('.layout-main-section').get(0),
query: 'select tabBlog.name, title, left(content, 300) as content, tabBlog.modified, \
parent: $(wrapper).find('#blog-list').get(0),
query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.modified, \
ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
from tabProfile, tabBlog\
where ifnull(published,1)=1 and tabBlog.owner = tabProfile.name',
where ifnull(published,0)=1 and tabBlog.owner = tabProfile.name',
hide_refresh: true,
no_toolbar: true,
render_row: function(parent, data) {
if(data.content.length==300) data.content += '...';
if(data.content && data.content.length==1000) data.content += '... (read on)';
data.content = wn.markdown(data.content);
if(data.last_name) data.last_name = ' ' + data.last_name;
data.date = prettyDate(data.modified);
parent.innerHTML = repl('<h3><a href="#!%(name)s">%(title)s</a></h3>\
<p><div class="help">By %(first_name)s %(last_name)s on %(date)s</div></p>\
<div class="comment">%(content)s</div><br>', data);
parent.innerHTML = repl('<h2>%(title)s</h2>\
<p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
<p>%(content)s</p>\
<a href="#!%(name)s">Read Full Text</a><br>', data);
},
page_length: 10
});