blob: 1212a84c8ec69a13164318eb93ac75fafb1e7cef [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),
21 query: 'select tabBlog.name, title, left(content, 1000) as content, tabBlog.creation, \
22 ifnull(first_name, "") as first_name, ifnull(last_name, "") as last_name \
23 from tabProfile, tabBlog\
24 where ifnull(published,0)=1 and tabBlog.owner = tabProfile.name \
25 order by tabBlog.creation desc',
26 hide_refresh: true,
27 no_toolbar: true,
28 render_row: function(parent, data) {
29 if(data.content && data.content.length==1000) {
30 data.content += repl('... <a href="%(name)s.html">(read on)</a>', data);
31 }
32 data.content = wn.markdown(data.content);
33 if(data.last_name) data.last_name = ' ' + data.last_name;
34 data.date = prettyDate(data.creation);
35 parent.innerHTML = repl('<h2><a href="%(name)s.html">%(title)s</a></h2>\
36 <p><div class="help">By %(first_name)s%(last_name)s, %(date)s</div></p>\
37 <p>%(content)s</p><br>', data)
38 //<a href="%(name)s.html">Read Full Text</a><br>', data);
39 },
40 page_length: 10
41 });
42 erpnext.blog_list.run();
Anand Doshi51146c02012-07-12 18:41:12 +053043}