コード例 #1
0
ファイル: views.py プロジェクト: blakev/quokka
    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
コード例 #2
0
ファイル: views.py プロジェクト: c0d34fun/quokka
    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()
コード例 #3
0
ファイル: views.py プロジェクト: c0d34fun/quokka
    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()
コード例 #4
0
ファイル: views.py プロジェクト: romulocollopy/quokka
    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'))
コード例 #5
0
ファイル: views.py プロジェクト: tonnyhjw/FlaskPyCMS
    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()
コード例 #6
0
ファイル: views.py プロジェクト: tonnyhjw/FlaskPyCMS
    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()
コード例 #7
0
ファイル: settings.py プロジェクト: wigginslab/quokka
def get_site_url():
    from quokka.core.models import Config
    try:
        from_site_config = Config.get('site', 'site_domain', None)
        from_settings = get_setting_value('SERVER_NAME', None)
        if from_settings and not from_settings.startswith('http'):
            from_settings = 'http://%s/' % from_settings
        return from_site_config or from_settings or request.url_root
    except RuntimeError:
        return 'http://localhost/'
コード例 #8
0
ファイル: views.py プロジェクト: c0d34fun/quokka
    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)
コード例 #9
0
    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)
コード例 #10
0
    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'))
コード例 #11
0
ファイル: views.py プロジェクト: c0d34fun/quokka
    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)
コード例 #12
0
    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)
コード例 #13
0
ファイル: views.py プロジェクト: tonnyhjw/FlaskPyCMS
    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
コード例 #14
0
 def test_has_default_theme(self):
     from quokka.core.models import Config
     self.assertTrue(Config.get('settings', 'DEFAULT_THEME') == 'pure')
コード例 #15
0
ファイル: test_basic.py プロジェクト: GraphGrail/quokka
 def test_has_default_theme(self):
     from quokka.core.models import Config
     self.assertTrue(Config.get('settings', 'DEFAULT_THEME') == 'default')
コード例 #16
0
ファイル: test_basic.py プロジェクト: faylau/quokka
    def test_has_default_theme(self):
        from quokka.core.models import Config

        self.assertTrue(Config.get("settings", "DEFAULT_THEME") == "default")