From fb0f96ef7a4f20848717cf330077ec955ce7025a Mon Sep 17 00:00:00 2001 From: Marc Garcia Date: Fri, 17 Jan 2020 16:51:20 +0000 Subject: [PATCH] WEB: Styling blog (#31094) --- web/pandas/community/blog.html | 8 ++++---- web/pandas_web.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/web/pandas/community/blog.html b/web/pandas/community/blog.html index ffe6f97d679e4..627aaa450893b 100644 --- a/web/pandas/community/blog.html +++ b/web/pandas/community/blog.html @@ -4,10 +4,10 @@ {% for post in blog.posts %}
-

{{ post.title }}

-
Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}
-
{{ post.summary }}
- Read +
{{ post.title }}
+
Source: {{ post.feed }} | Author: {{ post.author }} | Published: {{ post.published.strftime("%b %d, %Y") }}
+
{{ post.summary }}
+ Read more
{% endfor %} diff --git a/web/pandas_web.py b/web/pandas_web.py index d515d8a0e1cd7..45dafcf0c4c10 100755 --- a/web/pandas_web.py +++ b/web/pandas_web.py @@ -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 @@ -74,6 +75,7 @@ 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) @@ -81,6 +83,7 @@ def blog_add_posts(context): published = datetime.datetime.fromtimestamp( time.mktime(entry.published_parsed) ) + summary = re.sub(tag_expr, "", entry.summary) posts.append( { "title": entry.title, @@ -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)