blob: 8c9b9d7252beb9e17f7bdb4600532419a09a4d15 [file] [log] [blame]
Anand Doshi10bcf5e2012-06-26 18:54:10 +05301// ERPNext - web based ERP (http://erpnext.com)
2// Copyright (C) 2012 Web Notes Technologies Pvt Ltd
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17// js inside blog page
18wn.pages['{{ name }}'].onload = function(wrapper) {
19 erpnext.blog_list = new wn.ui.Listing({
20 parent: $(wrapper).find('#blog-list').get(0),
Anand Doshif01059f2012-07-13 00:46:59 +053021 method: 'website.blog.get_blog_list',
Anand Doshi10bcf5e2012-06-26 18:54:10 +053022 hide_refresh: true,
23 no_toolbar: true,
24 render_row: function(parent, data) {
Rushabh Mehtaaaa75492012-08-06 15:22:17 +053025 if(!data.comments) {
26 data.comment_text = 'No comments yet.'
Anand Doshi55137752012-08-23 17:17:46 +053027 } else if (data.comments===1) {
Rushabh Mehtaaaa75492012-08-06 15:22:17 +053028 data.comment_text = '1 comment.'
29 } else {
30 data.comment_text = data.comments + ' comments.'
31 }
32
Anand Doshi10bcf5e2012-06-26 18:54:10 +053033 if(data.content && data.content.length==1000) {
34 data.content += repl('... <a href="%(name)s.html">(read on)</a>', data);
35 }
Anand Doshi10bcf5e2012-06-26 18:54:10 +053036 parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\
Rushabh Mehtaaaa75492012-08-06 15:22:17 +053037 <div class="help">%(comment_text)s</div>\
Anand Doshi200c4432012-07-13 01:14:52 +053038 %(content)s<br /><br />', data);
Anand Doshi10bcf5e2012-06-26 18:54:10 +053039 },
40 page_length: 10
41 });
42 erpnext.blog_list.run();
Anand Doshi51146c02012-07-12 18:41:12 +053043}