Skip to content

Commit fb0f96e

Browse files
WEB: Styling blog (#31094)
1 parent a72eef5 commit fb0f96e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

web/pandas/community/blog.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
{% for post in blog.posts %}
55
<div class="card">
66
<div class="card-body">
7-
<h3 class="card-title"><a href="{{post.link }}" target="_blank">{{ post.title }}</a></h3>
8-
<h6 class="card-subtitle">Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</h6>
9-
<div class="card-text">{{ post.summary }}</div>
10-
<a class="card-link" href="{{post.link }}" target="_blank">Read</a>
7+
<h5 class="card-title"><a href="{{post.link }}" target="_blank">{{ post.title }}</a></h5>
8+
<h6 class="card-subtitle text-muted small mb-4">Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}</h6>
9+
<div class="card-text mb-2">{{ post.summary }}</div>
10+
<a class="card-link small" href="{{post.link }}" target="_blank">Read more</a>
1111
</div>
1212
</div>
1313
{% endfor %}

web/pandas_web.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@
2828
import importlib
2929
import operator
3030
import os
31+
import re
3132
import shutil
3233
import sys
3334
import time
3435
import typing
3536

3637
import feedparser
37-
import markdown
3838
import jinja2
39+
import markdown
3940
import requests
4041
import yaml
4142

@@ -74,13 +75,15 @@ def blog_add_posts(context):
7475
preprocessor fetches the posts in the feeds, and returns the relevant
7576
information for them (sorted from newest to oldest).
7677
"""
78+
tag_expr = re.compile("<.*?>")
7779
posts = []
7880
for feed_url in context["blog"]["feed"]:
7981
feed_data = feedparser.parse(feed_url)
8082
for entry in feed_data.entries:
8183
published = datetime.datetime.fromtimestamp(
8284
time.mktime(entry.published_parsed)
8385
)
86+
summary = re.sub(tag_expr, "", entry.summary)
8487
posts.append(
8588
{
8689
"title": entry.title,
@@ -89,7 +92,7 @@ def blog_add_posts(context):
8992
"feed": feed_data["feed"]["title"],
9093
"link": entry.link,
9194
"description": entry.description,
92-
"summary": entry.summary,
95+
"summary": summary,
9396
}
9497
)
9598
posts.sort(key=operator.itemgetter("published"), reverse=True)

0 commit comments

Comments
 (0)