// 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 . // js inside blog page $(document).ready(function() { // make list of blogs blog.get_list(); $("#next-page").click(function() { blog.get_list(); }) if(get_url_arg("by_name")) { $("#blog-title").html("Posts by " + get_url_arg("by_name")); } if(get_url_arg("category")) { $("#blog-title").html("Posts filed under " + get_url_arg("category")); } }); var blog = { start: 0, get_list: function() { $.ajax({ method: "GET", url: "server.py", data: { cmd: "website.helpers.blog.get_blog_list", start: blog.start, by: get_url_arg("by"), category: get_url_arg("category") }, dataType: "json", success: function(data) { $(".progress").toggle(false); if(data.exc) console.log(data.exc); blog.render(data.message); } }); }, render: function(data) { var $wrap = $("#blog-list"); $.each(data, function(i, b) { // comments if(!b.comments) { b.comment_text = 'No comments yet.' } else if (b.comments===1) { b.comment_text = '1 comment.' } else { b.comment_text = b.comments + ' comments.' } $(repl('
\
\
\ \
\
\
\

%(title)s

\

%(content)s

\

\ \ %(full_name)s wrote this on %(published)s / %(comment_text)s

\
\

', b)).appendTo($wrap); }); blog.start += (data.length || 0); if(!data.length || data.length < 20) { if(blog.start) { $("#next-page").toggle(false) .parent().append("
Nothing more to show.
"); } else { $("#next-page").toggle(false) .parent().append("
No blogs written yet.
"); } } else { $("#next-page").toggle(true); } } }