in bedrock/contentful/api.py [0:0]
def render(self, node):
url = urlparse(node["data"]["uri"])
request = get_current_request()
ref = ""
rel = ""
data_cta = ""
# add referral info to links to other mozilla properties
# TODO: can we make this just if url.netloc == "mozilla.org" or are we expecting
# subdomains, because we set the utm_source to www.mozilla.org
if "mozilla.org" in url.netloc and url.netloc != "www.mozilla.org":
# don't add if there's already utms
if "utm_" not in url.query:
params = {
"utm_source": "www.mozilla.org",
"utm_medium": "referral",
"utm_campaign": request.page_info["utm_campaign"],
}
add = "?" if url.query == "" else "&"
ref = add + urlencode(params)
# TODO, should this be based on the current server (ie dev, stage)?
# add attributes for external links
if url.netloc != "www.mozilla.org":
# add security measures
rel = ' rel="external noopener"'
# add analytics
cta_text = _make_plain_text(node)
data_cta = f' data-cta-text="{cta_text}"'
return f'<a href="{urlunparse(url)}{ref}"{data_cta}{rel}>{self._render_content(node)}</a>'