当前位置: 首页>>代码示例>>Python>>正文


Python atom.AtomFeed方法代码示例

本文整理汇总了Python中werkzeug.contrib.atom.AtomFeed方法的典型用法代码示例。如果您正苦于以下问题:Python atom.AtomFeed方法的具体用法?Python atom.AtomFeed怎么用?Python atom.AtomFeed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.contrib.atom的用法示例。


在下文中一共展示了atom.AtomFeed方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def get(self):
        title = SITE['title']
        subtitle = SITE['subtitle']
        feed = AtomFeed(
            '%s' % (title),
            feed_url=request.url,
            url=request.url_root,
            subtitle=subtitle)
        articles = Article.query.limit(10)
        for article in articles:
            feed.add(
                article.title,
                article.to_html(),
                content_type='html',
                author=article.user.username,
                url=urljoin(request.url_root,
                            url_for('blog.article', pk=article.id)),
                updated=article.updated_at,
                published=article.created_at)
        return feed.get_response() 
开发者ID:honmaple,项目名称:maple-blog,代码行数:22,代码来源:router.py

示例2: get_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def get_feed():
    from mhn.common.clio import Clio
    from mhn.auth import current_user
    authfeed = mhn.config['FEED_AUTH_REQUIRED']
    if authfeed and not current_user.is_authenticated():
        abort(404)
    feed = AtomFeed('MHN HpFeeds Report', feed_url=request.url,
                    url=request.url_root)
    sessions = Clio().session.get(options={'limit': 1000})
    for s in sessions:
        feedtext = u'Sensor "{identifier}" '
        feedtext += '{source_ip}:{source_port} on sensorip:{destination_port}.'
        feedtext = feedtext.format(**s.to_dict())
        feed.add('Feed', feedtext, content_type='text',
                 published=s.timestamp, updated=s.timestamp,
                 url=makeurl(url_for('api.get_session', session_id=str(s._id))))
    return feed 
开发者ID:CommunityHoneyNetwork,项目名称:CHN-Server,代码行数:19,代码来源:__init__.py

示例3: rss_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def rss_feed():
    feed = AtomFeed(
        'Patch Server Software Titles',
        feed_url=request.url,
        url=request.url_root,
        generator=('Patch Server', None, __version__))

    titles = SoftwareTitle.query.all()

    for title in titles:
        feed.add(
            title=title.name,
            author=title.publisher,
            content='<b>Version:</b> {} '
                    '<b>| App Name:</b> {} '
                    '<b>| Bundle ID:</b> {}'.format(
                        title.current_version, title.app_name, title.bundle_id),
            url=url_for(
                'patch_by_name_id', name_id=title.id_name, _external=True),
            updated=title.last_modified)

    return feed.get_response() 
开发者ID:brysontyrrell,项目名称:PatchServer,代码行数:24,代码来源:web_ui.py

示例4: _feed_rss

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def _feed_rss():
    feed = AtomFeed(title=config.sitename(), subtitle='Recent Articles',
                    feed_url=request.url, url=request.url_root, updated=datetime.now())

    for post in post_service.get_published_posts():
        feed.add(post.title, markdown.convert(post.html),
                 content_type='html',
                 author=post.user.username,
                 url=urljoin(request.url_root,  '/post/' + post.slug),
                 updated=post.updated,
                 published=post.created)
    return ''.join(feed.generate()) 
开发者ID:whiteclover,项目名称:white,代码行数:14,代码来源:front.py

示例5: recent_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def recent_feed():
    feed = AtomFeed(_('Last datasets'),
                    feed_url=request.url, url=request.url_root)
    datasets = (Dataset.objects.visible().order_by('-created_at')
                .limit(current_site.feed_size))
    for dataset in datasets:
        author = None
        if dataset.organization:
            author = {
                'name': dataset.organization.name,
                'uri': url_for('organizations.show',
                               org=dataset.organization.id, _external=True),
            }
        elif dataset.owner:
            author = {
                'name': dataset.owner.fullname,
                'uri': url_for('users.show',
                               user=dataset.owner.id, _external=True),
            }
        feed.add(dataset.title,
                 render_template('dataset/feed_item.html', dataset=dataset),
                 content_type='html',
                 author=author,
                 url=url_for('datasets.show',
                             dataset=dataset.id, _external=True),
                 updated=dataset.last_modified,
                 published=dataset.created_at)
    return feed.get_response() 
开发者ID:opendatateam,项目名称:udata,代码行数:30,代码来源:views.py

示例6: activity_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def activity_feed():
    activity_keys = request.args.getlist('key')

    feed = AtomFeed(
        current_app.config.get('SITE_TITLE'), feed_url=request.url,
        url=request.url_root)
    activities = (Activity.objects.order_by('-created_at')
                                  .limit(current_site.feed_size))

    for activity in activities.select_related():
        # filter by activity.key
        # /!\ this won't completely honour `feed_size` (only as a max value)
        if activity_keys and activity.key not in activity_keys:
            continue
        try:
            owner = activity.actor or activity.organization
        except DoesNotExist:
            owner = 'deleted'
            owner_url = None
        else:
            owner_url = owner.url_for(_external=True)
        try:
            related = activity.related_to
        except DoesNotExist:
            related = 'deleted'
            related_url = None
        else:
            related_url = related.url_for(_external=True)
        feed.add(
            id='%s#activity=%s' % (
                url_for('site.dashboard', _external=True), activity.id),
            title='%s by %s on %s' % (
                activity.key, owner, related),
            url=related_url,
            author={
                'name': owner,
                'uri': owner_url,
            },
            updated=activity.created_at
        )
    return feed.get_response() 
开发者ID:opendatateam,项目名称:udata,代码行数:43,代码来源:views.py

示例7: recent_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def recent_feed():
    feed = AtomFeed(_('Last reuses'),
                    feed_url=request.url, url=request.url_root)
    reuses = Reuse.objects.visible().order_by('-created_at').limit(15)
    for reuse in reuses:
        author = None
        if reuse.organization:
            author = {
                'name': reuse.organization.name,
                'uri': url_for('organizations.show',
                               org=reuse.organization.id, _external=True),
            }
        elif reuse.owner:
            author = {
                'name': reuse.owner.fullname,
                'uri': url_for('users.show',
                               user=reuse.owner.id, _external=True),
            }
        feed.add(reuse.title,
                 render_template('reuse/feed_item.html', reuse=reuse),
                 content_type='html',
                 author=author,
                 url=url_for('reuses.show', reuse=reuse.id, _external=True),
                 updated=reuse.created_at,
                 published=reuse.created_at)
    return feed.get_response() 
开发者ID:opendatateam,项目名称:udata,代码行数:28,代码来源:views.py

示例8: feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def feed():
    blogging_engine = _get_blogging_engine(current_app)
    storage = blogging_engine.storage
    config = blogging_engine.config
    count = config.get("BLOGGING_FEED_LIMIT")
    posts = storage.get_posts(count=count, offset=None, recent=True,
                              user_id=None, tag=None, include_draft=False)

    feed = AtomFeed(
        '%s - All Articles' % config.get("BLOGGING_SITENAME",
                                         "Flask-Blogging"),
        feed_url=request.url, url=request.url_root, generator=None)

    feed_posts_fetched.send(blogging_engine.app, engine=blogging_engine,
                            posts=posts)
    if len(posts):
        for post in posts:
            blogging_engine.process_post(post, render=True)
            feed.add(post["title"], ensureUtf(post["rendered_text"]),
                     content_type='html',
                     author=post["user_name"],
                     url=config.get("BLOGGING_SITEURL", "")+post["url"],
                     updated=post["last_modified_date"],
                     published=post["post_date"])
        feed_posts_processed.send(blogging_engine.app, engine=blogging_engine,
                                  feed=feed)
    response = feed.get_response()
    response.headers["Content-Type"] = "application/xml"
    return response 
开发者ID:gouthambs,项目名称:Flask-Blogging,代码行数:31,代码来源:views.py

示例9: feed_posts_processed_receiver

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def feed_posts_processed_receiver(sender, engine, feed):
    assert sender == engine.app
    isinstance(engine, BloggingEngine)
    isinstance(feed, AtomFeed)
    engine.ctr_feed_posts_processed += 1 
开发者ID:gouthambs,项目名称:Flask-Blogging,代码行数:7,代码来源:plugin.py

示例10: feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def feed():
    def convert_to_dict(p):
        post_d = p.to_dict()
        del post_d['raw_content']
        post_d['content'] = get_parser(p.format).parse_whole(p.raw_content)
        post_d['url'] = site['root_url'] + make_abs_url(p.unique_key)
        return post_d

    posts = map(convert_to_dict,
                islice(storage.get_posts(include_draft=False),
                       0, current_app.config['FEED_COUNT']))

    atom = AtomFeed(title=site['title'],
                    subtitle=site['subtitle'],
                    url=site['root_url'] + request.script_root,
                    feed_url=site['root_url'] + url_for('.feed'),
                    author=site.get('author'))
    for post_ in posts:
        atom.add(title=post_['title'],
                 content=post_['content'],
                 url=post_['url'],
                 id=post_['unique_key'],
                 published=post_['created'].replace(
                     tzinfo=timezone_from_str(site['timezone'])),
                 updated=post_['updated'].replace(
                     tzinfo=timezone_from_str(site['timezone'])),
                 author=post_['author'])

    response = make_response(atom.to_string())
    response.content_type = 'application/atom+xml; charset=utf-8'
    return response 
开发者ID:veripress,项目名称:veripress,代码行数:33,代码来源:views.py

示例11: generate_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def generate_feed():
    # app.logger.warning(request.args)

    param = request.args.get('username')
    if param:
        username = urllib.parse.unquote(param).strip()
        match, display = fetch.is_valid_username(username)

        if (match):
            # get posts
            site_url = fetch.build_site_url(username)
            data = fetch.get_remote_data(site_url)
            items = fetch.extract_items(username, data)

            if (items and len(items) > 0):
                # create feed
                feed = AtomFeed('{0} FB Posts'.format(display),
                                subtitle=site_url,
                                feed_url=request.url,
                                url=request.url_root)

                for post in items:
                    feed.add(post['title'],
                             post['article'],
                             content_type='html',
                             author=post['author'],
                             url=post['url'],
                             updated=post['date'],
                             published=post['date'])

                return feed.get_response()
            else:
                return 'No posts found. Are you sure you put in the correct username?'
        else:
            return 'Invalid username provided'
    else:
        return 'No username provided in query string'


# launch 
开发者ID:irfancharania,项目名称:fb-feed-gen,代码行数:42,代码来源:app.py

示例12: feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def feed(name):
    if current_app.config.get('PRIVATE_WIKI') and current_user.is_anonymous:
        return current_app.login_manager.unauthorized()
    cname = to_canonical(name)
    wiki_name = current_app.config['SITE_TITLE']
    start = 0
    length = int(request.args.get('length', 20))

    the_feed = AtomFeed(
        title="{} - Recent changes for page '{}'".format(wiki_name, cname),
        url=url_for('wiki.page', name=cname, _external=True),
        id="{}_pagefeed_{}".format(to_canonical(wiki_name), cname),
        feed_url=url_for('wiki.feed', name=cname, _external=True),
        generator=("Realms wiki", 'https://github.com/scragg0x/realms-wiki', __version__)
    )

    page = g.current_wiki.get_page(cname)
    items = list(itertools.islice(page.history, start, start + length))  # type: list[dict]

    for item in items:
        the_feed.add(
            title="Commit '{}'".format(item['sha']),
            content=item['message'],
            url=url_for('wiki.commit', name=name, sha=item['sha'], _external=True),
            id="{}/{}".format(item['sha'], cname),
            author=item['author'],
            updated=datetime.fromtimestamp(item['time'])
        )

    response = make_response((the_feed.to_string(), {'Content-type': 'application/atom+xml; charset=utf-8'}))
    response.add_etag()
    return response.make_conditional(request) 
开发者ID:scragg0x,项目名称:realms-wiki,代码行数:34,代码来源:views.py

示例13: recent_feed

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def recent_feed():
    feed = AtomFeed('WhibOx 2nd Edition -- CHES 2019 CTF',
                    feed_url=request.url, url=request.url_root,
                    author="WhibOx organizing committee",
                    subtitle="Submitted challenged order by published date descending"
                    )
    programs = Program.get_all_published_sorted_by_published_time()

    for program in programs:
        item_url = "%scandidate/%d" % (
            request.url_root, program._id)
        title = 'New challenge "<strong>%s</strong>" submitted' % program.funny_name
        author = program.user.displayname
        content = render_template('candidate.html', program=program, feed=True)

        if not author or not author.strip():
            author = program.user.username
        feed.add(id=item_url,
                 title=title,
                 title_type='html',
                 updated=datetime.fromtimestamp(program._timestamp_published),
                 author=author,
                 url=item_url,
                 categories=[{'term': program.status}],
                 content=content,
                 content_type='html',
                 )
    return feed.get_response() 
开发者ID:CryptoExperts,项目名称:wb_contest_submission_server,代码行数:30,代码来源:routes.py

示例14: get

# 需要导入模块: from werkzeug.contrib import atom [as 别名]
# 或者: from werkzeug.contrib.atom import AtomFeed [as 别名]
def get(self, name):
        setting = current_app.config.get('SITE', {
            'title': '',
            'description': ''
        })
        title = setting['title']
        description = setting['description']
        feed = AtomFeed(
            '%s·%s' % (name, title),
            feed_url=request.url,
            url=request.url_root,
            subtitle=description)
        topics = Topic.query.filter_by(tags__name=name).limit(10)
        for topic in topics:
            if topic.content_type == Topic.CONTENT_TYPE_MARKDOWN:
                content = topic.content
            else:
                content = topic.content
            feed.add(topic.title,
                     content,
                     content_type='html',
                     author=topic.author.username,
                     url=urljoin(
                         request.url_root,
                         url_for(
                             'topic.topic', topicId=topic.id)),
                     updated=topic.updated_at,
                     published=topic.created_at)
        return feed.get_response() 
开发者ID:honmaple,项目名称:maple-bbs,代码行数:31,代码来源:views.py


注:本文中的werkzeug.contrib.atom.AtomFeed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。