Skip to content

Commit

Permalink
WEB: Styling blog (pandas-dev#31094)
Browse files Browse the repository at this point in the history
  • Loading branch information
datapythonista authored Jan 17, 2020
1 parent a72eef5 commit fb0f96e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions web/pandas/community/blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
{% for post in blog.posts %}
<div class="card">
<div class="card-body">
<h3 class="card-title"><a href="{{post.link }}" target="_blank">{{ post.title }}</a></h3>
<h6 class="card-subtitle">Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</h6>
<div class="card-text">{{ post.summary }}</div>
<a class="card-link" href="{{post.link }}" target="_blank">Read</a>
<h5 class="card-title"><a href="{{post.link }}" target="_blank">{{ post.title }}</a></h5>
<h6 class="card-subtitle text-muted small mb-4">Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</h6>
<div class="card-text mb-2">{{ post.summary }}</div>
<a class="card-link small" href="{{post.link }}" target="_blank">Read more</a>
</div>
</div>
{% endfor %}
Expand Down
7 changes: 5 additions & 2 deletions web/pandas_web.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,15 @@
import importlib
import operator
import os
import re
import shutil
import sys
import time
import typing

import feedparser
import markdown
import jinja2
import markdown
import requests
import yaml

Expand Down Expand Up @@ -74,13 +75,15 @@ def blog_add_posts(context):
preprocessor fetches the posts in the feeds, and returns the relevant
information for them (sorted from newest to oldest).
"""
tag_expr = re.compile("<.*?>")
posts = []
for feed_url in context["blog"]["feed"]:
feed_data = feedparser.parse(feed_url)
for entry in feed_data.entries:
published = datetime.datetime.fromtimestamp(
time.mktime(entry.published_parsed)
)
summary = re.sub(tag_expr, "", entry.summary)
posts.append(
{
"title": entry.title,
Expand All @@ -89,7 +92,7 @@ def blog_add_posts(context):
"feed": feed_data["feed"]["title"],
"link": entry.link,
"description": entry.description,
"summary": entry.summary,
"summary": summary,
}
)
posts.sort(key=operator.itemgetter("published"), reverse=True)
Expand Down

0 comments on commit fb0f96e

Please sign in to comment.