Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

from wagtail.wagtailcore.models import Site 

 

from wagtailsharing.models import SharingSite 

 

 

def get_sharing_url(page): 

"""Get a sharing URL for the latest revision of a page, if available.""" 

url_parts = page.get_url_parts() 

 

if url_parts is None: 

# Page is not routable. 

return None 

 

site_id, root_url, page_path = url_parts 

 

site = Site.objects.get(id=site_id) 

 

try: 

sharing_site = site.sharing_site 

except SharingSite.DoesNotExist: 

# Site is not shared. 

return None 

 

return sharing_site.root_url + page_path