def make_atom(self, feed_name, contents): feed = AtomFeed( feed_name, feed_url=request.url, url=request.url_root ) for content in contents: if not content.channel.include_in_rss: continue if content.created_by: author = content.created_by.name else: author = Config.get('site', 'site_author', '') feed.add( content.title, cdata(content.get_text()), content_type="html", author=author, url=self.make_external_url(content.get_absolute_url()), updated=content.updated_at, published=content.created_at ) return feed
def make_rss(self, feed_name, contents): conf = current_app.config if not self.channel: # Feed view description = 'Articles with tag: ' + self.tag categories = [self.tag] else: # Tag View description = self.channel.get_text() categories = self.channel.tags rss = pyrss.RSS2( title=feed_name, link=request.url_root, # channel description after markdown processing description=description, language=conf.get('RSS_LANGUAGE', 'en-us'), copyright=conf.get('RSS_COPYRIGHT', 'All rights reserved.'), lastBuildDate=datetime.now(), categories=categories, ) # set rss.pubDate to the newest post in the collection # back 10 years in the past rss_pubdate = datetime.today() - timedelta(days=365 * 10) for content in contents: if not content.channel.include_in_rss: continue if content.created_at > rss_pubdate: rss_pubdate = content.created_at if content.created_by: author = content.created_by.name else: author = Config.get('site', 'site_author', '') rss.items.append( pyrss.RSSItem( title=content.title, link=content.get_absolute_url(), description=content.get_text(), author=author, categories=content.tags, guid=hashlib.sha1( content.title + content.get_absolute_url() ).hexdigest(), pubDate=content.created_at, ) ) # set the new published date after iterating the contents rss.pubDate = rss_pubdate return rss.to_xml(encoding=conf.get('RSS_ENCODING', 'utf-8'))
def get(self, tag): contents = self.get_contents(tag) if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), "Tag {0}".format(tag)) feed = self.make_atom(feed_name, contents) return feed.get_response()
def get(self, long_slug): contents = self.get_contents(long_slug) if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), self.channel.title) feed = self.make_atom(feed_name, contents) return feed.get_response()
def get(self, tag): contents = self.get_contents(tag) self.channel = None if current_app.config.get('PAGINATION_ENABLED', True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), "Tag {0}".format(tag)) return self.make_rss(feed_name, contents)
def make_rss(self, feed_name, contents): conf = current_app.config if not self.channel: # Feed view description = 'Articles with tag: ' + self.tag categories = [self.tag] else: # Tag View description = self.channel.get_text() categories = self.channel.tags rss = pyrss.RSS2( title=feed_name, link=request.url_root, # channel description after markdown processing description=description, language=conf.get('RSS_LANGUAGE', 'en-us'), copyright=conf.get('RSS_COPYRIGHT', 'All rights reserved.'), lastBuildDate=datetime.now(), categories=categories, ) # set rss.pubDate to the newest post in the collection # back 10 years in the past rss_pubdate = datetime.today() - timedelta(days=365 * 10) for content in contents: if not content.channel.include_in_rss: continue if content.created_at > rss_pubdate: rss_pubdate = content.created_at if content.created_by: author = content.created_by.name else: author = Config.get('site', 'site_author', '') rss.items.append( pyrss.RSSItem( title=content.title, link=content.get_absolute_url(), description=content.get_text(), author=author, categories=content.tags, guid=hashlib.sha1(content.title + content.get_absolute_url()).hexdigest(), pubDate=content.created_at, )) # set the new published date after iterating the contents rss.pubDate = rss_pubdate return rss.to_xml(encoding=conf.get('RSS_ENCODING', 'utf-8'))
def get(self, tag): contents = self.get_contents(tag) if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), "Tag {0}".format(tag) ) feed = self.make_atom(feed_name, contents) return feed.get_response()
def get(self, long_slug): contents = self.get_contents(long_slug) if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), self.channel.title ) feed = self.make_atom(feed_name, contents) return feed.get_response()
def get(self, long_slug): # instantiates the self.channel property contents = self.get_contents(long_slug) self.tag = None if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), self.channel.title) return self.make_rss(feed_name, contents)
def get(self, tag): contents = self.get_contents(tag) self.channel = None if current_app.config.get('PAGINATION_ENABLED', True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), "Tag {0}".format(tag) ) return self.make_rss(feed_name, contents)
def get(self, long_slug): # instantiates the self.channel property contents = self.get_contents(long_slug) self.tag = None if current_app.config.get("PAGINATION_ENABLED", True): contents = contents.items feed_name = u"{0} | {1} | feed".format( Config.get('site', 'site_name', ''), self.channel.title ) return self.make_rss(feed_name, contents)
def make_atom(self, feed_name, contents): feed = AtomFeed(feed_name, feed_url=request.url, url=request.url_root) for content in contents: if not content.channel.include_in_rss: continue if content.created_by: author = content.created_by.name else: author = Config.get('site', 'site_author', '') feed.add(content.title, cdata(content.get_text()), content_type="html", author=author, url=self.make_external_url(content.get_absolute_url()), updated=content.updated_at, published=content.created_at) return feed
def test_has_default_theme(self): from quokka.core.models.config import Config self.assertTrue(Config.get('settings', 'DEFAULT_THEME') == 'pure')
#!/usr/bin/python """ THIS SCRIPT CLEANS ALL DATA IN YOUR QUOKKA DB RUN ONLY IN OPENSHIFT DEMO DEPLOY OR AT YOUR OWN RISK!!!! """ from quokka import create_app from quokka.core.models.content import Content from quokka.core.models.config import Config from quokka.core.models.channel import Channel from quokka.modules.accounts.models import User app = create_app() Content.drop_collection() User.drop_collection() Config.drop_collection() Channel.drop_collection()