Skip to content

Commit bfbc068

Browse files
committedOct 7, 2021
[PYT-628]-RSS Feed Implementation to PyTorch page
1 parent fe04e78 commit bfbc068

File tree

4 files changed

+104
-0
lines changed

4 files changed

+104
-0
lines changed
 

Diff for: ‎Gemfile

+1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ group :jekyll_plugins do
55
gem "github-pages"
66
gem "jekyll-paginate-v2"
77
gem 'jekyll-autoprefixer'
8+
gem 'jekyll-feed'
89
end

Diff for: ‎Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,11 @@ PLATFORMS
267267
DEPENDENCIES
268268
github-pages
269269
jekyll-autoprefixer
270+
jekyll-feed
270271
jekyll-paginate-v2
271272

272273
RUBY VERSION
273274
ruby 2.5.1p57
274275

276+
BUNDLED WITH
277+
1.16.3

Diff for: ‎_includes/head.html

+1
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,5 @@
3232
{% include twitter_pixel.html %}
3333
{% endif %}
3434
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsearch.js@2/dist/cdn/docsearch.min.css" />
35+
<link href="{{ site.baseurl }}/feed.xml" type="application/atom+xml" rel="alternate" title="Pythorch Blog Posts" />
3536
</head>

Diff for: ‎feed.xml

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
layout: null
3+
collection: posts
4+
---
5+
6+
<?xml version="1.0" encoding="utf-8"?>
7+
{% if page.xsl %}
8+
<?xml-stylesheet type="text/xml" href="{{ '/feed.xslt.xml' | absolute_url }}"?>
9+
{% endif %}
10+
<feed xmlns="http://www.w3.org/2005/Atom" {% if site.lang %}xml:lang="{{ site.lang }}"{% endif %}>
11+
<generator uri="https://jekyllrb.com/" version="{{ jekyll.version }}">Jekyll</generator>
12+
<link href="{{ page.url | absolute_url }}" rel="self" type="application/atom+xml" />
13+
<link href="{{ '/' | absolute_url }}" rel="alternate" type="text/html" {% if site.lang %}hreflang="{{ site.lang }}" {% endif %}/>
14+
<updated>{{ site.time | date_to_xmlschema }}</updated>
15+
<id>{{ page.url | absolute_url | xml_escape }}</id>
16+
17+
{% assign title = site.title | default: site.name %}
18+
{% if page.collection != "posts" %}
19+
{% assign collection = page.collection | capitalize %}
20+
{% assign title = title | append: " | " | append: collection %}
21+
{% endif %}
22+
{% if page.category %}
23+
{% assign category = page.category | capitalize %}
24+
{% assign title = title | append: " | " | append: category %}
25+
{% endif %}
26+
27+
{% if title %}
28+
<title type="html">{{ title | smartify | xml_escape }}</title>
29+
{% endif %}
30+
31+
{% if site.description %}
32+
<subtitle>{{ site.description | xml_escape }}</subtitle>
33+
{% endif %}
34+
35+
{% if site.author %}
36+
<author>
37+
<name>{{ site.author.name | default: site.author | xml_escape }}</name>
38+
{% if site.author.email %}
39+
<email>{{ site.author.email | xml_escape }}</email>
40+
{% endif %}
41+
{% if site.author.uri %}
42+
<uri>{{ site.author.uri | xml_escape }}</uri>
43+
{% endif %}
44+
</author>
45+
{% endif %}
46+
47+
{% assign posts = site[page.collection] | where_exp: "post", "post.draft != true" | sort: "date" | reverse %}
48+
{% if page.category %}
49+
{% assign posts = posts | where: "category",page.category %}
50+
{% endif %}
51+
{% for post in posts limit: 10 %}
52+
<entry{% if post.lang %}{{" "}}xml:lang="{{ post.lang }}"{% endif %}>
53+
<title type="html">{{ post.title | smartify | strip_html | normalize_whitespace | xml_escape }}</title>
54+
<link href="{{ post.url | absolute_url }}" rel="alternate" type="text/html" title="{{ post.title | xml_escape }}" />
55+
<published>{{ post.date | date_to_xmlschema }}</published>
56+
<updated>{{ post.last_modified_at | default: post.date | date_to_xmlschema }}</updated>
57+
<id>{{ post.id | absolute_url | xml_escape }}</id>
58+
<content type="html" xml:base="{{ post.url | absolute_url | xml_escape }}">{{ post.content | strip | xml_escape }}</content>
59+
60+
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
61+
{% assign post_author = site.data.authors[post_author] | default: post_author %}
62+
{% assign post_author_email = post_author.email | default: nil %}
63+
{% assign post_author_uri = post_author.uri | default: nil %}
64+
{% assign post_author_name = post_author.name | default: post_author %}
65+
66+
<author>
67+
<name>{{ post_author_name | default: "" | xml_escape }}</name>
68+
{% if post_author_email %}
69+
<email>{{ post_author_email | xml_escape }}</email>
70+
{% endif %}
71+
{% if post_author_uri %}
72+
<uri>{{ post_author_uri | xml_escape }}</uri>
73+
{% endif %}
74+
</author>
75+
76+
{% if post.category %}
77+
<category term="{{ post.category | xml_escape }}" />
78+
{% endif %}
79+
80+
{% for tag in post.tags %}
81+
<category term="{{ tag | xml_escape }}" />
82+
{% endfor %}
83+
84+
{% if post.excerpt and post.excerpt != empty %}
85+
<summary type="html">{{ post.excerpt | strip_html | normalize_whitespace | xml_escape }}</summary>
86+
{% endif %}
87+
88+
{% assign post_image = post.image.path | default: post.image %}
89+
{% if post_image %}
90+
{% unless post_image contains "://" %}
91+
{% assign post_image = post_image | absolute_url %}
92+
{% endunless %}
93+
<media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="{{ post_image | xml_escape }}" />
94+
{% endif %}
95+
</entry>
96+
{% endfor %}
97+
</feed>
98+
99+

0 commit comments

Comments
 (0)
Please sign in to comment.