Skip to content
Snippets Groups Projects
Commit a21665bf authored by Ravi Singh's avatar Ravi Singh Committed by qsm-odoo
Browse files

[FIX] website: fix sharers of share snippet

The whatsapp sharer was fixed via [1]. This uses https for all sharers
and fix the pinterest one using the logo image with their new API.

[1]: https://github.com/odoo/odoo/commit/62575b75ff48a34df23f8742737226949f13c13c



closes odoo/odoo#53191

Signed-off-by: default avatarQuentin Smetz (qsm) <qsm@odoo.com>
Co-authored-by: default avatarjpr-odoo <jpr@openerp.com>
Co-authored-by: default avatarqsm-odoo <qsm@odoo.com>
parent 0c2f83f4
Branches
Tags
No related merge requests found
......@@ -10,14 +10,17 @@ const ShareWidget = publicWidget.Widget.extend({
* @override
*/
start: function () {
var urlRegex = /(\?(?:|.*&)(?:u|url|body)=)(.*?)(&|#|$)/;
var titleRegex = /(\?(?:|.*&)(?:title|text|subject)=)(.*?)(&|#|$)/;
var url = encodeURIComponent(window.location.href);
var title = encodeURIComponent($('title').text());
this.$('a').each(function () {
var $a = $(this);
$a.attr('href', function (i, href) {
return href.replace(urlRegex, function (match, a, b, c) {
const urlRegex = /(\?(?:|.*&)(?:u|url|body)=)(.*?)(&|#|$)/;
const titleRegex = /(\?(?:|.*&)(?:title|text|subject|description)=)(.*?)(&|#|$)/;
const mediaRegex = /(\?(?:|.*&)(?:media)=)(.*?)(&|#|$)/;
const url = encodeURIComponent(window.location.href);
const title = encodeURIComponent($('title').text());
const media = encodeURIComponent($('meta[property="og:image"]').attr('content'));
this.$('a').each((index, element) => {
const $a = $(element);
$a.attr('href', (i, href) => {
return href.replace(urlRegex, (match, a, b, c) => {
return a + url + c;
}).replace(titleRegex, function (match, a, b, c) {
if ($a.hasClass('s_share_whatsapp')) {
......@@ -29,6 +32,8 @@ const ShareWidget = publicWidget.Widget.extend({
return a + title + url + c;
}
return a + title + c;
}).replace(mediaRegex, (match, a, b, c) => {
return a + media + c;
});
});
if ($a.attr('target') && $a.attr('target').match(/_blank/i) && !$a.closest('.o_editable').length) {
......
......@@ -10,13 +10,13 @@
<a href="https://twitter.com/intent/tweet?text={title}&amp;url={url}" t-attf-class="s_share_twitter #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-twitter #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="http://www.linkedin.com/sharing/share-offsite/?url={url}" t-attf-class="s_share_linkedin #{_link_classes}" target="_blank">
<a href="https://www.linkedin.com/sharing/share-offsite/?url={url}" t-attf-class="s_share_linkedin #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-linkedin #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="https://wa.me/?text={title}" t-attf-class="s_share_whatsapp #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-whatsapp #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="http://pinterest.com/pin/create/button/?url={url}&amp;description={title}" t-attf-class="s_share_pinterest #{_link_classes}" target="_blank">
<a href="https://pinterest.com/pin/create/button/?url={url}&amp;media={media}&amp;description={title}" t-attf-class="s_share_pinterest #{_link_classes}" target="_blank">
<i t-attf-class="fa fa-pinterest #{not _link_classes and 'rounded shadow-sm'}"/>
</a>
<a href="mailto:?body={url}&amp;subject={title}" t-attf-class="s_share_email #{_link_classes}">
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment