From 1a9096d2ef4e70a4257cbd513da16fe903ca1403 Mon Sep 17 00:00:00 2001 From: "Mahendra Barad (OpenERP)" Date: Fri, 14 Mar 2014 18:04:12 +0530 Subject: [PATCH] [IMP]improved content share add author_name in share bzr revid: mba@tinyerp.com-20140314123412-5v20p2a8ym7dqpkr --- addons/website_blog/controllers/main.py | 2 ++ addons/website_blog/static/lib/contentshare.js | 4 ++-- addons/website_blog/static/src/js/website_blog.js | 10 +++++++--- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/addons/website_blog/controllers/main.py b/addons/website_blog/controllers/main.py index 080da19107c..bbe7c8e605e 100644 --- a/addons/website_blog/controllers/main.py +++ b/addons/website_blog/controllers/main.py @@ -334,6 +334,8 @@ class WebsiteBlog(http.Controller): @http.route('/blogpsot/get_custom_options', type='json', auth="public", website=True) def get_custom_options(self, post_id=0,image=None, **post): values = {} + post_obj = request.registry.get('blog.post').browse(request.cr, SUPERUSER_ID, int(post_id)) + values['author_name'] = post_obj.create_uid.name inherit_options = request.registry.get('ir.ui.view').search_read(request.cr, SUPERUSER_ID, [('name','in',['Allow comment in text','Select to Tweet'])], ['inherit_id','name']) for options in inherit_options: values[options.get('name')] = options.get('inherit_id') diff --git a/addons/website_blog/static/lib/contentshare.js b/addons/website_blog/static/lib/contentshare.js index 64a6a77a5ff..b60cc70a660 100644 --- a/addons/website_blog/static/lib/contentshare.js +++ b/addons/website_blog/static/lib/contentshare.js @@ -14,8 +14,8 @@ }, getContent : function() { var current_url = window.location.href - var selected_text = this.getSelection('string').substring(0,option.maxLength-(current_url.length+3)); - var text = encodeURIComponent('\"'+selected_text+'\" '+ current_url) + var selected_text = this.getSelection('string').substring(0,option.maxLength-(current_url.length+3)-(option.author_name.length+4)); + var text = encodeURIComponent('\"'+selected_text+'\" '+'--@'+option.author_name+' '+current_url) return ''; }, getSelection : function(share) { diff --git a/addons/website_blog/static/src/js/website_blog.js b/addons/website_blog/static/src/js/website_blog.js index 8354879c798..426ba47adbc 100644 --- a/addons/website_blog/static/src/js/website_blog.js +++ b/addons/website_blog/static/src/js/website_blog.js @@ -30,15 +30,18 @@ $(document).ready(function() { } //check custome options inline discussion and select to tweet(share) are checked. - openerp.jsonRpc("/blogpsot/get_custom_options", 'call', {}).then(function(res){ + openerp.jsonRpc("/blogpsot/get_custom_options", 'call', { + 'post_id': $('#blog_post_name').attr('data-oe-id') + }).then(function(res){ discussion = res['Allow comment in text']; share = res['Select to Tweet']; + var author_name = res['author_name'] var content = $("#blog_content p"); if(content.length && discussion){ $('#discussions_wrapper').empty(); new openerp.website.blog_discussion({'content' : content}); } - if (share) $("p").share(); + if (share) $("p,h3,h4,ul").share({'author_name':author_name}); }); $('.cover_footer').on('click',page_transist); $('a[href^="#blog_content"]').on('click', animate); @@ -67,9 +70,10 @@ $(document).ready(function() { $('main').append($(data).find('main').html()); page_upwards(); //bind again it takes control from now on, until page relaod. + var author_name = $(data).find('#blog_author:first').text() $(document).find('.cover_footer').on('click',page_transist); $(document).find('a[href^="#blog_content"]').on('click', animate); - if (share) $("p").share(); + if (share) $("p,h3,h4,ul").share({'author_name':author_name}); if (newLocation != window.location) history.pushState(null, null, newLocation); });