Ejemplo n.º 1
0
def _generate_feed_entry(feed, max_ssh_info, config, atom_path):
    now = arrow.now()
    fe = FeedEntry()
    fe.title(
        "Storm Surge Alert for {[tide gauge stn]}".format(
            config["storm surge feeds"]["feeds"][feed]
        )
    )
    fe.id(
        _build_tag_uri(
            now.format("YYYY-MM-DD"), feed, now, config["storm surge feeds"], atom_path
        )
    )
    fe.author(
        name="Salish Sea MEOPAR Project",
        uri=f'https://{config["storm surge feeds"]["domain"]}/',
    )
    fe.content(_render_entry_content(feed, max_ssh_info, config), type="html")
    fe.link(
        rel="alternate",
        type="text/html",
        href=f'https://{config["storm surge feeds"]["domain"]}/'
        f"storm-surge/forecast.html",
    )
    return fe
Ejemplo n.º 2
0
def build_entry(article, blog_uri):
    title = article["title"]["rendered"]
    slug = article["slug"]
    author = article["_embedded"]["author"][0]
    description = article["excerpt"]["rendered"]
    content = article["content"]["rendered"]
    published = f'{article["date_gmt"]} GMT'
    updated = f'{article["modified_gmt"]} GMT'
    link = f"{blog_uri}/{slug}"

    categories = []

    if "wp:term" in article["_embedded"]:
        for category in article["_embedded"]["wp:term"][1]:
            categories.append(
                dict(term=category["slug"], label=category["name"]))

    entry = FeedEntry()
    entry.title(title)
    entry.description(description)
    entry.content(content)
    entry.author(name=author["name"], email=author["name"])
    entry.link(href=link)
    entry.category(categories)
    entry.published(published)
    entry.updated(updated)

    return entry
Ejemplo n.º 3
0
def generate_item(msg):
    fe = FeedEntry()
    fe.author(msg.sent_from)
    fe.pubDate(msg.date)
    fe.title(msg.subject)
    # print(f"{fe.title()} - {fe.pubDate()}")
    content = msg.body.get("html")
    fe.description(content, isSummary=True)
    return fe
Ejemplo n.º 4
0
async def create_entry(article):
    heading = article.select_one(".main-article-heading-box")
    entry = FeedEntry()
    entry.id(heading.select_one("a").get("href"))
    entry.link(href=heading.select_one("a").get("href"))
    entry.title(" / ".join(s.text for s in heading.select("span")))
    name = article.select_one(".main-article-author-box a").text.strip()
    entry.author({"name": name})
    entry.summary(article.select_one(".perex-lim").text.strip())
    date = article.select_one(".main-article-author-box small").text.strip()
    date = datetime.strptime(date, "%d.%m.%Y, %H:%M")
    entry.published(date.replace(tzinfo=timezone.utc))
    return entry
Ejemplo n.º 5
0
def rss_entries(links, feed=None):
    entries = []
    for link in links:
        fe = FeedEntry()
        fe.title(link.title)
        fe.content(link.text)
        fe.summary("Post by {} in {}.".format(
            link.user.name, feed.name if feed else link.feed.name))
        fe.link(href=link.url)
        fe.published(link.created_at)
        fe.comments(link.url)
        fe.author(name=link.user.name)
        entries.append(fe)
    return entries
Ejemplo n.º 6
0
def _generate_feed_entry(feed, max_ssh_info, config, atom_path):
    now = arrow.now()
    fe = FeedEntry()
    fe.title('Storm Surge Alert for {[tide gauge stn]}'.format(
        config['storm surge feeds']['feeds'][feed]))
    fe.id(
        _build_tag_uri(now.format('YYYY-MM-DD'), feed, now,
                       config['storm surge feeds'], atom_path))
    fe.author(name='Salish Sea MEOPAR Project',
              uri=f'https://{config["storm surge feeds"]["domain"]}/')
    fe.content(_render_entry_content(feed, max_ssh_info, config), type='html')
    fe.link(rel='alternate',
            type='text/html',
            href=f'https://{config["storm surge feeds"]["domain"]}/'
            f'storm-surge/forecast.html')
    return fe
Ejemplo n.º 7
0
    def _build_feed(
        self, blog_url, feed_url, feed_title, feed_description, articles
    ):
        """
        Build the content for the feed
        :blog_url: string blog url
        :feed_url: string url
        :feed_title: string title
        :feed_description: string description
        :param articles: Articles to create feed from
        """
        feed = FeedGenerator()
        feed.generator("Python Feedgen")
        feed.title(feed_title)
        feed.description(feed_description)
        feed.link(href=feed_url, rel="self")

        for article in articles:
            title = article["title"]["rendered"]
            slug = article["slug"]
            author = article["_embedded"]["author"][0]
            description = article["excerpt"]["rendered"]
            content = article["content"]["rendered"]
            published = f'{article["date_gmt"]} GMT'
            updated = f'{article["modified_gmt"]} GMT'
            link = f"{blog_url}/{slug}"

            categories = []

            if "wp:term" in article["_embedded"]:
                for category in article["_embedded"]["wp:term"][1]:
                    categories.append(
                        dict(term=category["slug"], label=category["name"])
                    )

            entry = FeedEntry()
            entry.title(title)
            entry.description(description)
            entry.content(content)
            entry.author(name=author["name"], email=author["name"])
            entry.link(href=link)
            entry.category(categories)
            entry.published(published)
            entry.updated(updated)
            feed.add_entry(entry, order="append")

        return feed
Ejemplo n.º 8
0
    def feed_entry(notice, url_root):
        _id = notice.id
        title = f"{_id}: {notice.title}"
        description = notice.details
        published = notice.published
        notice_path = flask.url_for(".notice", notice_id=notice.id).lstrip("/")
        link = f"{url_root}{notice_path}"

        entry = FeedEntry()
        entry.id(link)
        entry.title(title)
        entry.description(description)
        entry.link(href=link)
        entry.published(f"{published} UTC")
        entry.author({"name": "Ubuntu Security Team"})

        return entry
Ejemplo n.º 9
0
def generate_feed(stored_topics):
    fg = feed_header()
    
    for topic_id in stored_topics:
        topic = stored_topics[topic_id]

        if len(topic['comments']['comments']):
            last_comment_time = topic['comments']['comments'][-1]['date']
        else:
            last_comment_time = topic['utc_date']
        entry_id = '{}_{}'.format(topic['id'], last_comment_time)

        title = topic['title']

        if is_title_blacklisted(title):
            continue

        text = topic['text']

        text = cleanup_html(text)

        summary = text
        if len(summary) > 400:
            summary = summary[:390] + '...'
        
        text += '<p>Автор: <b>{}</b></p>'.format(topic['author'])

        for comment in topic['comments']['comments']:
            rendered = render_comment(comment)
            if rendered:
                text += '<p>{}</p>'.format(rendered)
        
        text = text.replace('\n', '<br />')
        url = topic['link']
        author = topic['author']

        entry = FeedEntry()

        entry.id(entry_id)
        entry.title(title)
        # entry.description(summary)
        entry.content(text)
        entry.link({'href': url})
        entry.author({'name': author})
        fg.add_entry(entry)
    return fg
Ejemplo n.º 10
0
async def recent_episodes():
    logo_link = url_for('static', filename='favicon.png', _external=True)

    feed = FeedGenerator()
    feed.title('Arrowverse.info - Recent Episodes')
    feed.id(request.url_root)
    feed.link(href=request.url)
    feed.logo(logo_link)
    feed.icon(logo_link)
    feed.language('en')

    hide_shows_list = request.args.getlist('hide_show')

    newest_first_episode_list = get_full_series_episode_list(
        excluded_series=hide_shows_list)[::-1]

    for episode in newest_first_episode_list[:15]:
        title = '{series} - {episode_id} - {episode_name}'.format(**episode)
        content = '{series} {episode_id} {episode_name} will air on {air_date}'.format(
            **episode)
        show_dict = app.config['SHOW_DICT_WITH_NAMES'][episode['series']]
        data_source = f"{show_dict['root']}{show_dict['url']}"

        feed_entry = FeedEntry()
        feed_entry.id(data_source)
        feed_entry.link({'href': data_source})
        feed_entry.title(title)
        feed_entry.content(content, type='text')
        feed_entry.author(uri=show_dict['root'])

        feed.add_entry(feed_entry)

    response = await make_response(feed.atom_str(pretty=True))
    response.headers['Content-Type'] = 'application/atom+xml'

    return response