def index(): """ Displays an index page with the feed listing """ # get all the stuff we want feeds = Feed.objects() feed_count = feeds.count() topics = set([feed.category for feed in Feed.objects.only('category')]) feeds_topics_counts = len(topics) # TODO: probably should put this in the database along with the feed. feed_icons = { 'gaming': 'fa fa-gamepad', 'design': 'fa fa-building-o', 'business': 'fa fa-briefcase', 'cinema': 'fa fa-video-camera', 'data-science': 'fa fa-area-chart', 'cooking': 'fa fa-cutlery', 'sports': 'fa fa-futbol-o', 'books': 'fa fa-book', 'tech': 'fa fa-cogs', 'politics': 'fa fa-university', 'news': 'fa fa-newspaper-o', 'essays': 'fa fa-pencil-square-o', 'do-it-yourself': 'fa fa-wrench' } feeds_topics = {topic: Feed.objects(category=topic) for topic in topics} # load all the data into the templates/feed_list.html template return render_template('index.html', feeds=feeds, feeds_topics=feeds_topics, feed_count=feed_count, topic_count=feeds_topics_counts, feed_icons=feed_icons)
def index(): """ Displays an index page with the feed listing """ # get all the stuff we want feeds = Feed.objects() feed_count = feeds.count() topics = set([feed.category for feed in Feed.objects.only('category')]) feeds_topics_counts = len(topics) feeds_topics = {topic: Feed.objects(category=topic) for topic in topics} # load all the data into the templates/feed_list.html template return render_template('index.html', feeds=feeds, feeds_topics=feeds_topics, feed_count=feed_count, topic_count=feeds_topics_counts)
def feedinfo(self, path): """ Writes information about the feeds to disk for performing lookups on the feeds themselves from the object id in each individual post. """ fields = ('id', 'title', 'link', 'category', 'active') feeds = Feed.objects(category__in=self.categories).only(*fields) with open(path, 'w') as f: f.write(feeds.to_json(indent=2))
def feedinfo(self, path): """ Writes information about the feeds to disk for performing lookups on the feeds themselves from the object id in each individual post. """ fields = ('id', 'title', 'link', 'category', 'active') feeds = Feed.objects(category__in=self.categories).only(*fields) with open(path, 'w') as f: f.write(feeds.to_json(indent=2))
def test_load_opml_integrated(self): """ Test the integration of the ingest helper function """ self.assertEqual(Feed.objects.count(), 0) self.assertEqual(load_opml(FEEDLY), 36) self.assertEqual(Feed.objects.count(), 36) for feed in Feed.objects(): self.assertIn('xmlUrl', feed.urls) self.assertIn('htmlUrl', feed.urls)
def test_load_opml_integrated(self): """ Test the integration of the ingest helper function """ self.assertEqual(Feed.objects.count(), 0) self.assertEqual(load_opml(FEEDLY), 36) self.assertEqual(Feed.objects.count(), 36) for feed in Feed.objects(): self.assertIn('xmlUrl', feed.urls) self.assertIn('htmlUrl', feed.urls)
def feeds(self, categories=None): """ Returns a list of feeds for the specified categories """ if isinstance(categories, basestring): categories = [categories] elif categories is None: categories = self.categories for category in categories: for feed in Feed.objects(category=category): yield feed
def feeds(self, categories=None): """ Returns a list of feeds for the specified categories """ if isinstance(categories, basestring): categories = [categories] elif categories is None: categories = self.categories for category in categories: for feed in Feed.objects(category=category): yield feed
def feeds(self, categories=None): """ Returns a list of feeds for the specified categories. During export, this list is used to construct a feed-category mapping that is used to perform checking of sequential reads of Posts. """ if isinstance(categories, basestring): categories = [categories] elif categories is None: categories = self.categories else: categories = list(categories) return Feed.objects(category__in=categories)
def feeds(self, categories=None): """ Returns a list of feeds for the specified categories. During export, this list is used to construct a feed-category mapping that is used to perform checking of sequential reads of Posts. """ if isinstance(categories, basestring): categories = [categories] elif categories is None: categories = self.categories else: categories = list(categories) return Feed.objects(category__in=categories)
def index(): """ Displays an index page with the feed listing """ # get all the stuff we want feeds = Feed.objects() feed_count = feeds.count() topics = set([feed.category for feed in Feed.objects.only('category')]) feeds_topics_counts = len(topics) # TODO: probably should put this in the database along with the feed. feed_icons = {'gaming':'fa fa-gamepad', 'design':'fa fa-building-o', 'business':'fa fa-briefcase', 'cinema':'fa fa-video-camera', 'data-science':'fa fa-area-chart', 'cooking':'fa fa-cutlery', 'sports':'fa fa-futbol-o', 'books':'fa fa-book', 'tech':'fa fa-cogs', 'politics':'fa fa-university', 'news':'fa fa-newspaper-o', 'essays':'fa fa-pencil-square-o', 'do-it-yourself':'fa fa-wrench' } feeds_topics = { topic: Feed.objects(category=topic) for topic in topics } # load all the data into the templates/feed_list.html template return render_template('index.html', feeds=feeds, feeds_topics=feeds_topics, feed_count=feed_count, topic_count=feeds_topics_counts, feed_icons=feed_icons)