[IMP]improved content share add author_name in share

bzr revid: mba@tinyerp.com-20140314123412-5v20p2a8ym7dqpkr
This commit is contained in:
Mahendra Barad (OpenERP) 2014-03-14 18:04:12 +05:30
parent df2c6ea488
commit 1a9096d2ef
3 changed files with 11 additions and 5 deletions

View File

@ -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')

View File

@ -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 '<a onclick="window.open(\''+option.shareLink+text+'\',\'_'+option.target+'\',\'location=yes,height=570,width=520,scrollbars=yes,status=yes\')"><i class="fa fa-twitter fa-lg"/></a>';
},
getSelection : function(share) {

View File

@ -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);
});