Beispiel #1
0
    def _get_quote(self):
        sr = Subreddit._by_name(g.about_sr_quotes)
        quote_link = self._get_hot_posts(sr, count=1, shuffle=True,
            filter=lambda x: self.quote_title_re.match(x.title))[0]

        quote = self.quote_title_re.match(quote_link.title).groupdict()
        quote['date'] = parse_date_text(quote['date']) or quote_link._date
        quote['url'] = quote_link.url
        quote['author_url'] = getattr(quote_link, 'author_url', quote['url'])
        quote['via'] = quote['via'] or quote_link.author.name
        quote['via_url'] = '/user/' + quote['via']
        quote['comment_label'], quote['comment_class'] = comment_label(quote_link.num_comments)
        quote['permalink'] = quote_link.permalink
        return quote
Beispiel #2
0
    def _get_quote(self):
        sr = Subreddit._by_name(g.about_sr_quotes)
        quote_link = self._get_hot_posts(sr, count=1, shuffle=True,
            filter=lambda x: self.quote_title_re.match(x.title))[0]

        quote = self.quote_title_re.match(quote_link.title).groupdict()
        quote['date'] = parse_date_text(quote['date']) or quote_link._date
        quote['url'] = quote_link.url
        quote['author_url'] = getattr(quote_link, 'author_url', quote['url'])
        quote['via'] = quote['via'] or quote_link.author.name
        quote['via_url'] = '/user/' + quote['via']
        quote['comment_label'], quote['comment_class'] = \
                comment_label(quote_link.num_comments)
        quote['permalink'] = quote_link.permalink
        return quote
    def _get_quote(self):
        sr = Subreddit._by_name(g.about_sr_quotes)
        quote_link = self._get_hot_posts(
            sr, count=1, shuffle=True, filter=lambda x: self.quote_title_re.match(x.title)
        )[0]

        quote = self.quote_title_re.match(quote_link.title).groupdict()
        quote["date"] = parse_date_text(quote["date"]) or quote_link._date
        quote["url"] = quote_link.url
        quote["author_url"] = getattr(quote_link, "author_url", quote["url"])
        quote["via"] = quote["via"] or quote_link.author.name
        quote["via_url"] = "/user/" + quote["via"]
        quote["comment_label"], quote["comment_class"] = comment_label(quote_link.num_comments)
        quote["permalink"] = quote_link.permalink
        return quote
Beispiel #4
0
    def _get_images(self):
        sr = Subreddit._by_name(g.about_sr_images)
        image_links = self._get_hot_posts(sr, count=g.about_images_count,
            filter=lambda x: self.image_title_re.match(x.title)
                             and x.score >= g.about_images_min_score)

        images = []
        for image_link in image_links:
            image = self.image_title_re.match(image_link.title).groupdict()
            image['url'] = image_link.url
            image['src'] = getattr(image_link, 'slideshow_src', static('about/slideshow/%s.jpg' % image_link._id36))
            image['author_url'] = getattr(image_link, 'author_url', image['url'])
            image['via'] = image['via'] or image_link.author.name
            image['via_url'] = '/user/' + image['via']
            image['comment_label'], image['comment_class'] = comment_label(image_link.num_comments)
            image['permalink'] = image_link.permalink
            images.append(image)
        return images
Beispiel #5
0
    def _get_images(self):
        sr = Subreddit._by_name(g.about_sr_images)
        image_links = self._get_hot_posts(sr, count=g.about_images_count,
            filter=lambda x: self.image_title_re.match(x.title)
                             and x.score >= g.about_images_min_score)

        images = []
        for image_link in image_links:
            image = self.image_title_re.match(image_link.title).groupdict()
            image['url'] = image_link.url
            default_src = static('about/slideshow/%s.jpg' % image_link._id36)
            image['src'] = getattr(image_link, 'slideshow_src', default_src)
            image['author_url'] = getattr(image_link, 'author_url', image['url'])
            image['via'] = image['via'] or image_link.author.name
            image['via_url'] = '/user/' + image['via']
            image['comment_label'], image['comment_class'] = \
                    comment_label(image_link.num_comments)
            image['permalink'] = image_link.permalink
            images.append(image)
        return images
Beispiel #6
0
    def _get_images(self):
        sr = Subreddit._by_name(g.about_sr_images)
        image_links = self._get_hot_posts(
            sr,
            count=g.about_images_count,
            filter=lambda x: self.image_title_re.match(x.title) and x.score >= g.about_images_min_score,
        )

        images = []
        for image_link in image_links:
            image = self.image_title_re.match(image_link.title).groupdict()
            image["url"] = image_link.url
            image["src"] = getattr(image_link, "slideshow_src", static("about/slideshow/%s.jpg" % image_link._id36))
            image["author_url"] = getattr(image_link, "author_url", image["url"])
            image["via"] = image["via"] or image_link.author.name
            image["via_url"] = "/user/" + image["via"]
            image["comment_label"], image["comment_class"] = comment_label(image_link.num_comments)
            image["permalink"] = image_link.permalink
            images.append(image)
        return images