[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#79891 X-original-commit: 45497060d9185e7fddb3fc6fcfcbcb81040c8d8b Signed-off-by: Quentin Smetz (qsm) <qsm@odoo.com> Co-authored-by: jpr-odoo <jpr@openerp.com> Co-authored-by: qsm-odoo <qsm@odoo.com>
This commit is contained in:
committed by
qsm-odoo
co-authored by
jpr-odoo
qsm-odoo
parent
2dfad96bce
commit
fde251330d
@@ -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 t-if="not _exclude_share_links or not 'twitter' in _exclude_share_links" href="https://twitter.com/intent/tweet?text={title}&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 t-if="not _exclude_share_links or not 'linkedin' in _exclude_share_links" href="http://www.linkedin.com/sharing/share-offsite/?url={url}" t-attf-class="s_share_linkedin #{_link_classes}" target="_blank">
|
||||
<a t-if="not _exclude_share_links or not 'linkedin' in _exclude_share_links" 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 t-if="not _exclude_share_links or not 'whatsapp' in _exclude_share_links" 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 t-if="not _exclude_share_links or not 'pinterest' in _exclude_share_links" href="http://pinterest.com/pin/create/button/?url={url}&description={title}" t-attf-class="s_share_pinterest #{_link_classes}" target="_blank">
|
||||
<a t-if="not _exclude_share_links or not 'pinterest' in _exclude_share_links" href="https://pinterest.com/pin/create/button/?url={url}&media={media}&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 t-if="not _exclude_share_links or not 'email' in _exclude_share_links" href="mailto:?body={url}&subject={title}" t-attf-class="s_share_email #{_link_classes}">
|
||||
|
||||
Reference in New Issue
Block a user