Beispiel #1
0
 def item_extra_kwargs(self, item):
     kwargs = {
         'when': '%s %s ago' % (
             item.when_prefix(),
             simpletimesince(item.when()))
         }
     if item.website_url:
         kwargs['website_url'] = iri_to_uri(item.website_url)
     if item.has_thumbnail:
         site = Site.objects.get_current()
         if item.thumbnail_url:
             kwargs['thumbnail'] = iri_to_uri(item.thumbnail_url)
         else:
             default_url = default_storage.url(
                 item.get_resized_thumb_storage_path(375, 295))
             if not (default_url.startswith('http://') or
                     default_url.startswith('https://')):
                 default_url = 'http://%s%s' % (site.domain, default_url)
             kwargs['thumbnail'] = default_url
         kwargs['thumbnails_resized'] = resized = {}
         for size in Video.THUMB_SIZES:
             url = default_storage.url(
                 item.get_resized_thumb_storage_path(*size))
             if not (url.startswith('http://') or
                     url.startswith('http://')):
                 url = 'http://%s%s' % (site.domain, url)
             resized[size] = url
     if item.embed_code:
         kwargs['embed_code'] = item.embed_code
     return kwargs
Beispiel #2
0
    def item_extra_kwargs(self, item):
        kwargs = {
            'when':
            '%s %s ago' % (item.when_prefix(), simpletimesince(item.when()))
        }
        if item.website_url:
            kwargs['website_url'] = iri_to_uri(item.website_url)
        # adjusted is set in self._bulk_adjusted_items.
        if not item._adjusted[THUMBNAIL_SIZES[0]]:
            kwargs['thumbnail_url'] = ''
        else:
            url = full_url(item._adjusted[THUMBNAIL_SIZES[0]]['url'])
            kwargs['thumbnail'] = iri_to_uri(url)

            if self.feed_type is JSONGenerator:
                # Version 2 of the MC widgets expect a
                # 'thumbnails_resized' argument which includes thumbnails
                # of these sizes for the various sizes of widget. These
                # are only here for backwards compatibility with those
                # widgets.
                kwargs['thumbnails_resized'] = []

                for size in THUMBNAIL_SIZES[1:]:
                    info_dict = item._adjusted.get(size, {})
                    url = full_url(info_dict.get('url', ''))
                    kwargs['thumbnails_resized'].append({
                        'width': size[0],
                        'height': size[1],
                        'url': url
                    })
        if item.embed_code:
            kwargs['embed_code'] = item.embed_code
        return kwargs
Beispiel #3
0
 def item_extra_kwargs(self, item):
     kwargs = {
         'when':
         '%s %s ago' % (item.when_prefix(), simpletimesince(item.when()))
     }
     if item.website_url:
         kwargs['website_url'] = iri_to_uri(item.website_url)
     if item.has_thumbnail:
         site = Site.objects.get_current()
         if item.thumbnail_url:
             kwargs['thumbnail'] = iri_to_uri(item.thumbnail_url)
         else:
             default_url = default_storage.url(
                 item.get_resized_thumb_storage_path(375, 295))
             if not (default_url.startswith('http://')
                     or default_url.startswith('https://')):
                 default_url = 'http://%s%s' % (site.domain, default_url)
             kwargs['thumbnail'] = default_url
         kwargs['thumbnails_resized'] = resized = {}
         for size in Video.THUMB_SIZES:
             url = default_storage.url(
                 item.get_resized_thumb_storage_path(*size))
             if not (url.startswith('http://')
                     or url.startswith('http://')):
                 url = 'http://%s%s' % (site.domain, url)
             resized[size] = url
     if item.embed_code:
         kwargs['embed_code'] = item.embed_code
     return kwargs
    def item_extra_kwargs(self, item):
        kwargs = {
            'when': '%s %s ago' % (
                item.when_prefix(),
                simpletimesince(item.when()))
        }
        if item.website_url:
            kwargs['website_url'] = iri_to_uri(item.website_url)
        # adjusted is set in self._bulk_adjusted_items.
        if not item._adjusted[THUMBNAIL_SIZES[0]]:
            kwargs['thumbnail_url'] = ''
        else:
            url = full_url(item._adjusted[THUMBNAIL_SIZES[0]]['url'])
            kwargs['thumbnail'] = iri_to_uri(url)

            if self.feed_type is JSONGenerator:
                # Version 2 of the MC widgets expect a
                # 'thumbnails_resized' argument which includes thumbnails
                # of these sizes for the various sizes of widget. These
                # are only here for backwards compatibility with those
                # widgets.
                kwargs['thumbnails_resized'] = []

                for size in THUMBNAIL_SIZES[1:]:
                    info_dict = item._adjusted.get(size, {})
                    url = full_url(info_dict.get('url', ''))
                    kwargs['thumbnails_resized'].append({'width': size[0],
                                                         'height': size[1],
                                                         'url': url})
        if item.embed_code:
            kwargs['embed_code'] = item.embed_code
        return kwargs
Beispiel #5
0
 def item_extra_kwargs(self, item):
     kwargs = {
         'when':
         '%s %s ago' % (item.when_prefix(), simpletimesince(item.when()))
     }
     if item.website_url:
         kwargs['website_url'] = iri_to_uri(item.website_url)
     if item.has_thumbnail:
         site = Site.objects.get_current()
         image = None
         if item.thumbnail_url:
             thumbnail_url = iri_to_uri(item.thumbnail_url)
         else:
             try:
                 image = Image.objects.for_storage_path(item.thumbnail_path)
             except Image.DoesNotExist:
                 thumbnail_url = ''
             else:
                 adjusted = AdjustedImage.objects.adjust(image, 375, 295)
                 thumbnail_url = adjusted.adjusted.url
                 if not (thumbnail_url.startswith('http://')
                         or thumbnail_url.startswith('https://')):
                     thumbnail_url = 'http://%s%s' % (site.domain,
                                                      thumbnail_url)
         kwargs['thumbnail'] = thumbnail_url
         if thumbnail_url and self.feed_type is JSONGenerator:
             # Version 2 of the MC widgets expect a 'thumbnails_resized'
             # argument which includes thumbnails of these sizes for the
             # various sizes of widget.  These are only here for backwards
             # compatibility with those widgets.
             thumbnails_resized = kwargs['thumbnails_resized'] = []
             if image is None:
                 image = Image.objects.for_storage_path(item.thumbnail_path)
             for size in (
                 (222, 169),  # large widget
                 (140, 110),  # medium widget
                 (88, 68)):  # small widget
                 adjusted = AdjustedImage.objects.adjust(image, *size)
                 thumbnail_url = adjusted.adjusted.url
                 if not (thumbnail_url.startswith('http://')
                         or thumbnail_url.startswith('https://')):
                     thumbnail_url = 'http://%s%s' % (site.domain,
                                                      thumbnail_url)
                 thumbnails_resized.append({
                     'width': size[0],
                     'height': size[1],
                     'url': thumbnail_url
                 })
     if item.embed_code:
         kwargs['embed_code'] = item.embed_code
     return kwargs
Beispiel #6
0
 def item_extra_kwargs(self, item):
     kwargs = {
         'when': '%s %s ago' % (
             item.when_prefix(),
             simpletimesince(item.when()))
         }
     if item.website_url:
         kwargs['website_url'] = iri_to_uri(item.website_url)
     if item.has_thumbnail:
         site = Site.objects.get_current()
         image = None
         if item.thumbnail_url:
             thumbnail_url = iri_to_uri(item.thumbnail_url)
         else:
             try:
                 image = Image.objects.for_storage_path(
                             item.thumbnail_path)
             except Image.DoesNotExist:
                 thumbnail_url = ''
             else:
                 adjusted = AdjustedImage.objects.adjust(image, 375, 295)
                 thumbnail_url = adjusted.adjusted.url
                 if not (thumbnail_url.startswith('http://') or
                         thumbnail_url.startswith('https://')):
                     thumbnail_url = 'http://%s%s' % (site.domain,
                                                      thumbnail_url)
         kwargs['thumbnail'] = thumbnail_url
         if thumbnail_url and self.feed_type is JSONGenerator:
             # Version 2 of the MC widgets expect a 'thumbnails_resized'
             # argument which includes thumbnails of these sizes for the
             # various sizes of widget.  These are only here for backwards
             # compatibility with those widgets.
             thumbnails_resized = kwargs['thumbnails_resized'] = []
             if image is None:
                 image = Image.objects.for_storage_path(
                     item.thumbnail_path)
             for size in ((222, 169), # large widget
                          (140, 110), # medium widget
                          (88, 68)):  # small widget
                 adjusted = AdjustedImage.objects.adjust(image, *size)
                 thumbnail_url = adjusted.adjusted.url
                 if not (thumbnail_url.startswith('http://') or
                         thumbnail_url.startswith('https://')):
                     thumbnail_url = 'http://%s%s' % (site.domain,
                                                      thumbnail_url)
                 thumbnails_resized.append({'width': size[0],
                                            'height': size[1],
                                            'url': thumbnail_url})
     if item.embed_code:
         kwargs['embed_code'] = item.embed_code
     return kwargs