2012-06-22 14:31:07 +00:00
|
|
|
{% extends "page.html" %}
|
|
|
|
|
|
|
|
{% block javascript %}
|
2012-02-23 07:05:32 +00:00
|
|
|
// 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/>.
|
|
|
|
|
2012-01-27 10:27:17 +00:00
|
|
|
// js inside blog page
|
2012-06-22 14:31:07 +00:00
|
|
|
wn.pages['{{ name }}'].onload = function(wrapper) {
|
2012-01-27 10:27:17 +00:00
|
|
|
// sidebar
|
2012-03-07 12:49:41 +00:00
|
|
|
wrapper.recent_list = new wn.ui.Listing({
|
2012-04-26 13:31:35 +00:00
|
|
|
parent: $(wrapper).find('.recent-posts'),
|
|
|
|
no_toolbar: true,
|
2012-01-27 10:27:17 +00:00
|
|
|
query: 'select name, title, left(content, 100) as content from tabBlog\
|
2012-06-22 14:31:07 +00:00
|
|
|
where ifnull(published,0)=1 and name!="{{ name }}" order by creation desc',
|
2012-01-27 10:27:17 +00:00
|
|
|
hide_refresh: true,
|
|
|
|
render_row: function(parent, data) {
|
2012-05-10 10:14:36 +00:00
|
|
|
//console.log(data);
|
2012-04-26 13:31:35 +00:00
|
|
|
if(data.content && data.content.length==100) data.content += '...';
|
2012-05-09 06:12:52 +00:00
|
|
|
parent.innerHTML = repl('<a href="%(name)s.html">%(title)s</a>\
|
2012-01-27 10:27:17 +00:00
|
|
|
<div class="comment">%(content)s</div><br>', data);
|
|
|
|
},
|
2012-04-26 13:31:35 +00:00
|
|
|
page_length: 5,
|
2012-01-27 10:27:17 +00:00
|
|
|
});
|
|
|
|
wrapper.recent_list.run();
|
2012-06-22 14:31:07 +00:00
|
|
|
|
2012-03-07 12:49:41 +00:00
|
|
|
wrapper.comment_list = new wn.ui.Listing({
|
2012-04-26 13:31:35 +00:00
|
|
|
parent: $(wrapper).find('.blog-comments').get(0),
|
|
|
|
no_toolbar: true,
|
2012-05-19 05:23:15 +00:00
|
|
|
query: 'select comment, comment_by_fullname, creation\
|
2012-03-30 06:59:06 +00:00
|
|
|
from `tabComment` where comment_doctype="Page"\
|
2012-06-22 14:31:07 +00:00
|
|
|
and comment_docname="{{ name }}" order by creation desc',
|
2012-01-27 10:27:17 +00:00
|
|
|
no_result_message: 'Be the first one to comment',
|
|
|
|
render_row: function(parent, data) {
|
2012-05-19 05:23:15 +00:00
|
|
|
data.comment_date = prettyDate(data.creation);
|
2012-01-27 10:27:17 +00:00
|
|
|
$(parent).html(repl("<div style='color:#777'>\
|
2012-02-08 07:03:13 +00:00
|
|
|
%(comment_by_fullname)s | %(comment_date)s:\
|
2012-01-27 10:27:17 +00:00
|
|
|
</div>\
|
|
|
|
<p style='margin-left: 20px;'>%(comment)s</p><br>", data))
|
|
|
|
},
|
2012-06-22 14:31:07 +00:00
|
|
|
hide_refresh: true,
|
2012-01-27 10:27:17 +00:00
|
|
|
});
|
|
|
|
wrapper.comment_list.run();
|
2012-06-22 14:31:07 +00:00
|
|
|
|
2012-01-27 10:27:17 +00:00
|
|
|
// add comment
|
2012-04-26 13:31:35 +00:00
|
|
|
$(wrapper).find('.layout-main-section').append('<br><button class="btn add-comment">\
|
2012-01-27 10:27:17 +00:00
|
|
|
Add Comment</button>');
|
|
|
|
$(wrapper).find('button.add-comment').click(function(){
|
|
|
|
d = new wn.widgets.Dialog({
|
|
|
|
title: 'Add Comment',
|
|
|
|
fields: [
|
|
|
|
{fieldname:'comment_by_fullname', label:'Your Name', reqd:1, fieldtype:'Data'},
|
|
|
|
{fieldname:'comment_by', label:'Email Id', reqd:1, fieldtype:'Data'},
|
|
|
|
{fieldname:'comment', label:'Comment', reqd:1, fieldtype:'Text'},
|
|
|
|
{fieldname:'post', label:'Post', fieldtype:'Button'}
|
|
|
|
]
|
|
|
|
});
|
|
|
|
d.fields_dict.post.input.onclick = function() {
|
|
|
|
var btn = this;
|
|
|
|
var args = d.get_values();
|
|
|
|
if(!args) return;
|
|
|
|
args.comment_doctype = 'Page';
|
2012-06-22 14:31:07 +00:00
|
|
|
args.comment_docname = '{{ name }}';
|
2012-01-27 10:27:17 +00:00
|
|
|
$(btn).set_working();
|
|
|
|
$c('webnotes.widgets.form.comments.add_comment', args, function(r) {
|
|
|
|
$(btn).done_working();
|
|
|
|
d.hide();
|
|
|
|
wrapper.comment_list.refresh();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
d.show();
|
|
|
|
})
|
2012-06-22 14:31:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
{% endblock %}
|