Opened 3 years ago

Last modified 13 months ago

#23829 new Cleanup/optimization

Allow customizing the `ping_google` URL

Reported by: Julian Wachholz Owned by:
Component: contrib.sitemaps Version: master
Severity: Normal Keywords: sitemaps, ping_google
Cc: me@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: yes
Easy pickings: no UI/UX: no

Description

The django.contrib.sitemaps.ping_google function currently does not allow modification of the protocol and will always send Google a "http://" link.

Maybe we should also add a way to supply an absolute URL (including a protocol) to the function so we can run this from CLI without having contrib.sites installed.

Change History (7)

comment:1 Changed 3 years ago by Danilo Bargen

Component: contrib.sitemapsDocumentation
Needs documentation: set
Owner: changed from nobody to Danilo Bargen
Status: newassigned
Triage Stage: UnreviewedAccepted

Why would you want to change the protocol?

Anyways, there actually is a way to change the ping URL: https://github.com/django/django/blob/master/django/contrib/sitemaps/__init__.py#L17 It probably needs a doc update though.

comment:2 Changed 3 years ago by Burhan Khalid

This does not change the scheme, it just changes the URL. The scheme is hard coded (see https://github.com/django/django/blob/master/django/contrib/sitemaps/__init__.py#L42). In addition, this relies on django.contrib.sites, which is not enabled by default.

I would like to propose a fix to this which adds two optional commands to the ping_google method:

  • is_secure, which will flag for https:// (defaults to False)
  • site_domain which can be used to pass in the domain if django.contrib.sites is not used.

Here are my proposed changes: https://github.com/burhan/django/tree/ticket_23829

comment:3 Changed 3 years ago by Danilo Bargen

Owner: Danilo Bargen deleted
Status: assignednew

Ah, you're talking about the scheme of the sitemap URL... Would you mind creating a pull request against master? That would make review easier :)

Here's my (now incomplete) pull request with doc updates: https://github.com/django/django/pull/3527

comment:4 Changed 3 years ago by Burhan Khalid

Pull request done, and I am getting some help in writing tests as well. See https://github.com/django/django/pull/3528

Last edited 3 years ago by Burhan Khalid (previous) (diff)

comment:5 Changed 3 years ago by Berker Peksag

Patch needs improvement: set

comment:6 Changed 3 years ago by Tim Graham

Component: Documentationcontrib.sitemaps
Has patch: set
Needs documentation: unset
Summary: `ping_google` uses hardcoded http protocolAllow customizing the `ping_google` URL

comment:8 Changed 13 months ago by Adam (Chainz) Johnson

Cc: me@… added
Note: See TracTickets for help on using tickets.
Back to Top