def output_feed(self, results, feed_title, feed_description,
                    feed_link, feed_url, navigation_urls, feed_guid):

        author_name = config.get('ckan.feeds.author_name', '').strip() or \
            config.get('ckan.site_id', '').strip()
        author_link = config.get('ckan.feeds.author_link', '').strip() or \
            config.get('ckan.site_url', '').strip()

        feed = _FixedAtom1Feed(
            title=feed_title,
            link=feed_link,
            description=feed_description,
            language=u'en',
            author_name=author_name,
            author_link=author_link,
            feed_guid=feed_guid,
            feed_url=feed_url,
            previous_page=navigation_urls['previous'],
            next_page=navigation_urls['next'],
            first_page=navigation_urls['first'],
            last_page=navigation_urls['last'],
        )

        if c.language == 'fr':
            def lx(x):
                return x + '_fra'
        else:
            def lx(x):
                return x

        for pkg in results:
            feed.add_item(
                title=pkg.get(lx('title'), ''),
                link=self.base_url + url(str(
                    '/api/action/package_show?id=%s' % pkg['name'])
                ),
                description=pkg.get(lx('notes'), ''),
                updated=date_str_to_datetime(pkg.get('metadata_modified')),
                published=date_str_to_datetime(pkg.get('metadata_created')),
                unique_id=_create_atom_id(u'/dataset/%s' % pkg['id']),
                author_name=pkg.get('author', ''),
                author_email=pkg.get('author_email', ''),
                categories=''.join(e['value']
                                   for e in pkg.get('extras', [])
                                   if e['key'] == lx('keywords')).split(','),
                enclosure=webhelpers.feedgenerator.Enclosure(
                    self.base_url + url(str(
                        '/api/action/package_show?id=%s' % pkg['name'])),
                    unicode(len(json.dumps(pkg))),   # TODO fix this
                    u'application/json')
            )
        response.content_type = feed.mime_type
        return feed.writeString('utf-8')
Esempio n. 2
0
    def output_feed(self, results, feed_title, feed_description, feed_link,
                    feed_url, navigation_urls, feed_guid):

        author_name = config.get('ckan.feeds.author_name', '').strip() or \
            config.get('ckan.site_id', '').strip()
        author_link = config.get('ckan.feeds.author_link', '').strip() or \
            config.get('ckan.site_url', '').strip()

        feed = _FixedAtom1Feed(
            title=feed_title,
            link=feed_link,
            description=feed_description,
            language=u'en',
            author_name=author_name,
            author_link=author_link,
            feed_guid=feed_guid,
            feed_url=feed_url,
            previous_page=navigation_urls['previous'],
            next_page=navigation_urls['next'],
            first_page=navigation_urls['first'],
            last_page=navigation_urls['last'],
        )

        if c.language == 'fr':

            def lx(x):
                return x + '_fra'
        else:

            def lx(x):
                return x

        for pkg in results:
            feed.add_item(
                title=pkg.get(lx('title'), ''),
                link=self.base_url +
                url(str('/api/action/package_show?id=%s' % pkg['name'])),
                description=pkg.get(lx('notes'), ''),
                updated=date_str_to_datetime(pkg.get('metadata_modified')),
                published=date_str_to_datetime(pkg.get('metadata_created')),
                unique_id=_create_atom_id(u'/dataset/%s' % pkg['id']),
                author_name=pkg.get('author', ''),
                author_email=pkg.get('author_email', ''),
                categories=''.join(e['value'] for e in pkg.get('extras', [])
                                   if e['key'] == lx('keywords')).split(','),
                enclosure=webhelpers.feedgenerator.Enclosure(
                    self.base_url +
                    url(str('/api/action/package_show?id=%s' % pkg['name'])),
                    unicode(len(json.dumps(pkg))),  # TODO fix this
                    u'application/json'))
        response.content_type = feed.mime_type
        return feed.writeString('utf-8')
Esempio n. 3
0
    def output_feed(self, results, feed_title, feed_description, feed_link, feed_url, navigation_urls, feed_guid):

        author_name = config.get("ckan.feeds.author_name", "").strip() or config.get("ckan.site_id", "").strip()
        author_link = config.get("ckan.feeds.author_link", "").strip() or config.get("ckan.site_url", "").strip()

        feed = _FixedAtom1Feed(
            title=feed_title,
            link=feed_link,
            description=feed_description,
            language=u"en",
            author_name=author_name,
            author_link=author_link,
            feed_guid=feed_guid,
            feed_url=feed_url,
            previous_page=navigation_urls["previous"],
            next_page=navigation_urls["next"],
            first_page=navigation_urls["first"],
            last_page=navigation_urls["last"],
        )

        if c.language == "fr":

            def lx(x):
                return x + "_fra"

        else:

            def lx(x):
                return x

        for pkg in results:
            feed.add_item(
                title=pkg.get(lx("title"), ""),
                link=self.base_url + url(str("/api/action/package_show?id=%s" % pkg["name"])),
                description=pkg.get(lx("notes"), ""),
                updated=date_str_to_datetime(pkg.get("metadata_modified")),
                published=date_str_to_datetime(pkg.get("metadata_created")),
                unique_id=_create_atom_id(u"/dataset/%s" % pkg["id"]),
                author_name=pkg.get("author", ""),
                author_email=pkg.get("author_email", ""),
                categories="".join(e["value"] for e in pkg.get("extras", []) if e["key"] == lx("keywords")).split(","),
                enclosure=webhelpers.feedgenerator.Enclosure(
                    self.base_url + url(str("/api/action/package_show?id=%s" % pkg["name"])),
                    unicode(len(json.dumps(pkg))),  # TODO fix this
                    u"application/json",
                ),
            )
        response.content_type = feed.mime_type
        return feed.writeString("utf-8")
Esempio n. 4
0
 def blog_proxy(self):
     return render("page/blog.html",
                   extra_vars={
                       'src_url':
                       h.url('/', locale='default', qualified=False) +
                       '_blog/'
                   })
Esempio n. 5
0
 def pager_url(self, page, partial=None, **kwargs):
     routes_dict = _pylons_default_url.environ['pylons.routes_dict']
     kwargs['controller'] = routes_dict['controller']
     kwargs['action'] = routes_dict['action']
     if routes_dict.get('id'):
         kwargs['id'] = routes_dict['id']
     kwargs['page'] = page
     return re.sub(r'\blad\b', self._guess_group_type(), h.url(**kwargs))
Esempio n. 6
0
 def logout(self):
     # Do any plugin logout stuff
     for item in p.PluginImplementations(p.IAuthenticator):
         item.logout()
     url = h.url('home')
     h.redirect_to(
         self._get_repoze_handler('logout_handler_path') + '?came_from=' +
         url)
Esempio n. 7
0
def _enclosure(pkg):
    links = []
    links.append({
        u'href': h.url(u'api.action', logic_function=u'package_show',
                       ver=3, id=pkg['id'], _external=True),
        u'rel': u'',
        u'length': text_type(len(json.dumps(pkg))),
        u'type': u'application/json'})
    return links
Esempio n. 8
0
File: feed.py Progetto: bwica/origin
def _enclosure(pkg):
    links = []
    links.append({
        u'href': h.url(u'api.action', logic_function=u'package_show',
                       ver=3, id=pkg['id'], _external=True),
        u'rel': u'',
        u'length': text_type(len(json.dumps(pkg))),
        u'type': u'application/json'})
    return links
 def submit_terms(self):
     ua = UserAgreement()
     came_from = request.params.get('came_from', h.url('/'))
     if not came_from:
         base.abort(400, _('Missing Value') + ': url')
     if h.url_is_local(came_from):
         ua.insert_new_agreement()
         response.set_cookie('wprdc_user_terms', 'true')
         return base.redirect(came_from)
     else:
         base.abort(403, _('Redirecting to external site is not allowed.'))