Skip to content

WEB: Styling blog #31094

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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