Opened on 07/26/2017 at 05:55:57 PM

Closed on 01/17/2019 at 08:50:03 PM

#5452 closed change (fixed)

Improve CMS API for local link generation

Reported by: kvas Assignee: rhowell
Priority: Unknown Milestone:
Module: Sitescripts Keywords:
Cc: juliandoucette Blocked By:
Blocking: Platform: Unknown / Cross platform
Ready: no Confidential: no
Tester: Unknown Verified working: no
Review URL(s):

Description (last modified by kvas)


Linkify filter, that is used for generating page links in CMS, breaks display of links in HTML editors and doesn't work well with HTML linters. The problem is that linkify generates the whole <a ...> tag, where it would be better if it generated only the attributes of an <a ...> tag. We would like to have lower level primitives for generating links (available as global functions) that could be used for constructing <a ...> tags in a way that they still look pretty much like <a ...> tags in the template or page source.

What to change

Create two global functions:

  • get_page_url(page[, locale, redirect=False]) that accepts a page path and locale and returns a full url based on website configuration and arguments. If locale is not provided, a link with the locale of the current page should be generated. By default, the function should verify that the page exists in the target locale and should raise an exception if it doesn't. But, if redirect is set to True, it should return the URL in the default locale. If the source has been configured to use relative links, the returned link should be relative.
  • page_has_locale(page, locale) that accepts a page path and locale and returns True if the page exists in that locale and False if it doesn't.

Implementation notes:

  • The base url should be configurable in the website settings via siteurl variable that already exists.
  • Most of the code that generates the links already exists in cms/

Attachments (0)

Change History (7)

comment:1 Changed on 07/06/2018 at 11:20:47 PM by rhowell

  • Owner set to rhowell

comment:2 Changed on 10/10/2018 at 03:00:25 PM by kvas

  • Description modified (diff)

comment:3 Changed on 01/11/2019 at 11:47:38 PM by rhowell

  • Review URL(s) modified (diff)
  • Status changed from new to reviewing

comment:4 Changed on 01/14/2019 at 02:49:37 PM by rhowell

  • Description modified (diff)

comment:5 Changed on 01/14/2019 at 04:06:32 PM by kvas

  • Description modified (diff)

comment:6 Changed on 01/17/2019 at 08:46:03 PM by abpbot

A commit referencing this issue has landed:
Issue 5452 - Improve CMS API for local link generation

comment:7 Changed on 01/17/2019 at 08:50:03 PM by rhowell

  • Resolution set to fixed
  • Status changed from reviewing to closed

Add Comment

Modify Ticket

Change Properties
as closed .
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from rhowell.
Note: See TracTickets for help on using tickets.