def patch_collected_context_extra(app, name, template, context):
  if template == "aggregated.html":
    for metadata in context["posts"]:
        metadata.body = patch_links_extra(
            metadata.body,
            metadata.link[:11], # first 11 characters is path (YYYY/MM/DD/)
            metadata.link[11:]) # following characters represent filename
        metadata.body = strip_xml_declaration(metadata.body)
Example #2
0
def generate_feed(app):
    '''
    Generates RSS feed.
    '''
    env = app.builder.env

    # don't do anything if no posts are available
    if not env.blog_posts:
        return

    context = dict()

    # feed items
    context["items"] = []
    for post in env.blog_posts:
        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(time.mktime(
            env.blog_metadata[post].date.timetuple()),
                                           localtime=True)

        categories = [
            category[1]
            for category in env.blog_metadata[post].filing["categories"]
        ]

        if 'PHP' not in categories:
            continue

        context["items"].append({
            "title":
            env.titles[post].astext(),
            "link":
            link,
            "description":
            patch.strip_xml_declaration(
                patch.patch_links(env.blog_metadata[post].body,
                                  app.config.website + post[:11])),
            "categories":
            categories,
            "pubDate":
            timestamp
        })

    if not context["items"]:
        return

    # feed metadata
    context["title"] = app.config.project
    context["link"] = app.config.website
    context["description"] = app.config.tagline
    context["language"] = "en-us"

    # feed pubDate is equal to latest post pubDate
    context["pubDate"] = context["items"][0]["pubDate"]

    yield ("php", context, "rss.html")
Example #3
0
def patch_collected_context_extra(app, name, template, context):
    if template == "aggregated.html":
        for metadata in context["posts"]:
            metadata.body = patch_links_extra(
                metadata.body,
                metadata.
                link[:11],  # first 11 characters is path (YYYY/MM/DD/)
                metadata.link[11:])  # following characters represent filename
            metadata.body = strip_xml_declaration(metadata.body)
Example #4
0
def generate_feed(app):
    '''
    Generates RSS feed.
    '''
    env = app.builder.env

    # don't do anything if no posts are available
    if not env.blog_posts:
        return

    context = dict()

    # feed items
    context["items"] = []
    for post in env.blog_posts:
        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(time.mktime(
            env.blog_metadata[post].date.timetuple()),
                                           localtime=True)

        categories = [
            category[1]
            for category in env.blog_metadata[post].filing["categories"]
        ]

        context["items"].append({
            "title":
            env.titles[post].astext(),
            "link":
            link,
            "description":
            patch.strip_xml_declaration(
                patch.patch_links(
                    env.blog_metadata[post].body,
                    app.config.website +
                    post[:11],  # first 11 characters is path (YYYY/MM/DD/)
                    post[11:],  # following characters represent filename
                    replace_read_more_link=not app.config.
                    rss_generate_full_posts)),
            "categories":
            categories,
            "pubDate":
            timestamp
        })

    # feed metadata
    context["title"] = app.config.project
    context["link"] = app.config.website
    context["tagline"] = app.config.tagline
    context["language"] = "en-us"

    # feed pubDate is equal to latest post pubDate
    context["pubDate"] = context["items"][0]["pubDate"]

    yield ("rss", context, "rss.html")
Example #5
0
def make_feed_context(app, feed_name, posts):
    env = app.builder.env
    context = dict()

    # feed items
    context["items"] = []
    for post in posts:
        link = "%s%s%s" % (app.config.website, post,
                           app.config.html_link_suffix)

        timestamp = email.utils.formatdate(time.mktime(
            env.blog_metadata[post].date.timetuple()),
                                           localtime=True)

        categories = [
            category[1]
            for category in env.blog_metadata[post].filing["categories"]
        ]

        description = patch.strip_xml_declaration(
            patch.patch_links(
                env.blog_metadata[post].body,
                # first 11 characters of post is the path (YYYY/MM/DD/)
                app.config.website + post[:11],
                # following characters represent filename
                post[11:],
                replace_read_more_link=not app.config.rss_generate_full_posts,
            ), )
        description = remove_header_link(description)

        context["items"].append({
            "title": env.titles[post].astext(),
            "link": link,
            "description": description,
            "categories": categories,
            "pubDate": timestamp
        })

    # feed metadata
    if feed_name:
        context["title"] = "%s - %s" % (app.config.project, feed_name)
    else:
        context["title"] = app.config.project
    context["link"] = app.config.website
    context["tagline"] = app.config.tagline
    context["language"] = "en-us"

    # feed pubDate is equal to latest post pubDate
    if context['items']:
        context["pubDate"] = context["items"][0]["pubDate"]

    return context
Example #6
0
def make_feed_context(app, feed_name, posts):
    env = app.builder.env
    context = dict()

    # feed items
    context["items"] = []
    for post in posts:
        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(
            time.mktime(env.blog_metadata[post].date.timetuple()),
            localtime=True)

        categories = [category[1] for category in
                      env.blog_metadata[post].filing["categories"]]

        description = patch.strip_xml_declaration(
            patch.patch_links(
                env.blog_metadata[post].body,
                # first 11 characters of post is the path (YYYY/MM/DD/)
                app.config.website + post[:11],
                # following characters represent filename
                post[11:],
                replace_read_more_link=not app.config.rss_generate_full_posts,
            ),
        )
        description = remove_header_link(description)

        context["items"].append({
            "title": env.titles[post].astext(),
            "link": link,
            "description": description,
            "categories": categories,
            "pubDate": timestamp
        })

    # feed metadata
    if feed_name:
        context["title"] = "%s - %s" % (app.config.project, feed_name)
    else:
        context["title"] = app.config.project
    context["link"] = app.config.website
    context["tagline"] = app.config.tagline
    context["language"] = "en-us"

    # feed pubDate is equal to latest post pubDate
    if context['items']:
        context["pubDate"] = context["items"][0]["pubDate"]

    return context
Example #7
0
def generate_feed(app):
    '''
    Generates RSS feed.
    '''
    env = app.builder.env
 
    # don't do anything if no posts are available
    if not env.blog_posts:
        return

    context = dict()

    # feed items
    context["items"] = []
    for post in env.blog_posts:
        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(
                time.mktime(env.blog_metadata[post].date.timetuple()),
                localtime=True)

        categories = [category[1] for category in env.blog_metadata[post].filing["categories"]]

        if 'PHP' not in categories:
            continue

        context["items"].append({
                    "title": env.titles[post].astext(),
                    "link": link,
                    "description": patch.strip_xml_declaration(patch.patch_links(
                            env.blog_metadata[post].body, 
                            app.config.website + post[:11])),
                    "categories": categories,
                    "pubDate": timestamp
                })

    if not context["items"]:
        return

    # feed metadata 
    context["title"] = app.config.project
    context["link"] = app.config.website
    context["description"] = app.config.tagline
    context["language"] = "en-us"
  
    # feed pubDate is equal to latest post pubDate
    context["pubDate"] = context["items"][0]["pubDate"]

    yield ("php", context, "rss.html")
Example #8
0
def generate_feed(app):
    '''
    Generates RSS feed.
    '''
    env = app.builder.env
 
    # don't do anything if no posts are available
    if not env.blog_posts:
        return

    context = dict()

    # feed items
    context["items"] = []
    for post in env.blog_posts:
        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(
                time.mktime(env.blog_metadata[post].date.timetuple()),
                localtime=True)

        categories = [category[1] for category in env.blog_metadata[post].filing["categories"]]

        context["items"].append({
                    "title": env.titles[post].astext(),
                    "link": link,
                    "description": patch.strip_xml_declaration(patch.patch_links(
                            env.blog_metadata[post].body, 
                            app.config.website + post[:11], # first 11 characters is path (YYYY/MM/DD/)
                            post[11:], # following characters represent filename
                            replace_read_more_link=not app.config.rss_generate_full_posts)),
                    "categories": categories,
                    "pubDate": timestamp
                })

    # feed metadata 
    context["title"] = app.config.project
    context["link"] = app.config.website
    context["tagline"] = app.config.tagline
    context["language"] = "en-us"
  
    # feed pubDate is equal to latest post pubDate
    context["pubDate"] = context["items"][0]["pubDate"]

    yield ("rss", context, "rss.html")
Example #9
0
def generate_feed(app, feed_name, posts):
    """
    Generates RSS feed.
    """
    env = app.builder.env

    context = {"items": []}

    for post in posts:
        metadata = env.blog_metadata[post]

        link = "%s%s.html" % (app.config.website, post)

        timestamp = email.utils.formatdate(time.mktime(metadata.date.timetuple()), localtime=True)

        categories = [category[1] for category in metadata.filing["categories"]]

        context["items"].append(
            {
                "title": env.titles[post].astext(),
                "link": link,
                "description": patch.strip_xml_declaration(
                    patch.patch_links(
                        metadata.body,
                        app.config.website + post[:11],  # first 11 characters is path (YYYY/MM/DD/)
                        post[11:],  # following characters represent filename
                        replace_read_more_link=not app.config.rss_generate_full_posts,
                    )
                ),
                "categories": categories,
                "pubDate": timestamp,
            }
        )

    # feed metadata
    context["title"] = "%s - %s" % (app.config.project, feed_name)
    context["link"] = app.config.website
    context["tagline"] = app.config.tagline
    context["language"] = "en-us"

    # feed pubDate is equal to latest post pubDate
    context["pubDate"] = context["items"][0]["pubDate"]

    return (feed_name, context, "rss.html")