+
+
+@register.inclusion_tag('social/carousel.html')
+def carousel(slug):
+ # TODO: cache
+ try:
+ carousel = Carousel.objects.get(slug=slug)
+ except Carousel.DoesNotExist:
+ # TODO: add sanity check for install.
+ carousel = None
+ return {
+ 'carousel': carousel
+ }
+
+
+@register.inclusion_tag('social/embed_video.html')
+def embed_video(url):
+ m = re.match(r'https://www.youtube.com/watch\?v=([^&;]+)', url)
+ return {
+ 'youtube_id': m.group(1) if m else None,
+ }