Anand Doshi | 10bcf5e | 2012-06-26 18:54:10 +0530 | [diff] [blame] | 1 | // 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 |
| 18 | wn.pages['{{ name }}'].onload = function(wrapper) { |
| 19 | erpnext.blog_list = new wn.ui.Listing({ |
| 20 | parent: $(wrapper).find('#blog-list').get(0), |
Anand Doshi | f01059f | 2012-07-13 00:46:59 +0530 | [diff] [blame] | 21 | method: 'website.blog.get_blog_list', |
Anand Doshi | 10bcf5e | 2012-06-26 18:54:10 +0530 | [diff] [blame] | 22 | hide_refresh: true, |
| 23 | no_toolbar: true, |
| 24 | render_row: function(parent, data) { |
Rushabh Mehta | aaa7549 | 2012-08-06 15:22:17 +0530 | [diff] [blame] | 25 | if(!data.comments) { |
| 26 | data.comment_text = 'No comments yet.' |
Anand Doshi | 5513775 | 2012-08-23 17:17:46 +0530 | [diff] [blame] | 27 | } else if (data.comments===1) { |
Rushabh Mehta | aaa7549 | 2012-08-06 15:22:17 +0530 | [diff] [blame] | 28 | data.comment_text = '1 comment.' |
| 29 | } else { |
| 30 | data.comment_text = data.comments + ' comments.' |
| 31 | } |
| 32 | |
Anand Doshi | 10bcf5e | 2012-06-26 18:54:10 +0530 | [diff] [blame] | 33 | if(data.content && data.content.length==1000) { |
| 34 | data.content += repl('... <a href="%(name)s.html">(read on)</a>', data); |
| 35 | } |
Anand Doshi | 10bcf5e | 2012-06-26 18:54:10 +0530 | [diff] [blame] | 36 | parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\ |
Rushabh Mehta | aaa7549 | 2012-08-06 15:22:17 +0530 | [diff] [blame] | 37 | <div class="help">%(comment_text)s</div>\ |
Anand Doshi | 200c443 | 2012-07-13 01:14:52 +0530 | [diff] [blame] | 38 | %(content)s<br /><br />', data); |
Anand Doshi | 10bcf5e | 2012-06-26 18:54:10 +0530 | [diff] [blame] | 39 | }, |
| 40 | page_length: 10 |
| 41 | }); |
| 42 | erpnext.blog_list.run(); |
Anand Doshi | 51146c0 | 2012-07-12 18:41:12 +0530 | [diff] [blame] | 43 | } |