1
0
mirror of https://github.com/danbee/danbarber.me synced 2025-03-04 08:59:10 +00:00

Generate manual feeds for posts and photos

This commit is contained in:
Daniel Barber 2018-09-25 21:12:11 -04:00
parent d168e28674
commit b1026210ab
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
9 changed files with 166 additions and 14 deletions

View File

@ -16,7 +16,6 @@ group :jekyll_plugins do
git: "https://github.com/danbee/jekyll-picture-tag.git",
branch: "update-gemspec"
gem "jekyll-video-tag"
gem "jekyll-json-feed"
end
gem "jekyll-staging"
@ -29,6 +28,6 @@ gem "facets"
gem "pry"
gem "uglifier"
gem "sass"
gem "bourbon"
gem "sass"
gem "uglifier"

View File

@ -56,8 +56,6 @@ GEM
pathutil (>= 0.8)
rack (~> 1.6)
sprockets (~> 3.3, < 3.8)
jekyll-json-feed (1.0.0)
jekyll (~> 3.3)
jekyll-paginate (1.1.0)
jekyll-sass-converter (1.5.2)
sass (~> 3.4)
@ -126,7 +124,6 @@ DEPENDENCIES
jekyll
jekyll-archives
jekyll-assets
jekyll-json-feed
jekyll-paginate
jekyll-picture-tag!
jekyll-staging

View File

@ -15,16 +15,12 @@ markdown: Kramdown
description: Web designer and developer for thoughtbot in London. Drummer and all
round musician.
subscribe_rss: "/atom.xml"
subscribe_json: "/feed.json"
plugins:
- jekyll-paginate
- jekyll-archives
- jekyll-assets
- jekyll-picture-tag
- jekyll_video_tag
- jekyll-json-feed
- bourbon
simple_search: https://duckduckgo.com/

View File

@ -10,9 +10,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover">
<!-- Links -->
<link rel="alternate" type="application/atom+xml" title="{{site.title}}" href="{{ site.url }}{{ site.subscribe_rss }}">
<link rel="alternate" type="application/json" title="{{site.title}}" href="{{ site.url }}{{ site.subscribe_json }}">
<link rel="canonical" href="{{ canonical }}">
<link rel="alternate" type="application/atom+xml" title="{{site.title}}" href="{{ site.url }}/feed.xml">
<link rel="alternate" type="application/json" title="{{site.title}}" href="{{ site.url }}/feed.json">
<link rel="alternate" type="application/atom+xml" title="{{site.title}} - Photos" href="{{ site.url }}/feed.photos.xml">
<link rel="alternate" type="application/json" title="{{site.title}} - Photos" href="{{ site.url }}/feed.photos.json">
<!-- Large favicon for Opera Speed Dial -->
<link rel="icon" type="image/png" href="{{ 'speeddial-icon.png' | asset_path }}">

View File

@ -1,3 +1,4 @@
/cv https://cv.danbarber.me 301
/invaders https://danbee.github.io/invaders 301
/canvas https://danbee.github.io/canvas 301
/atom.xml /feed.xml 301

66
feed.json Normal file
View File

@ -0,0 +1,66 @@
---
layout:
---
{
"version": "https://jsonfeed.org/version/1",
{% if site.title %}
"title": {{ site.title | smartify | jsonify }},
{% elsif site.name %}
"title": {{ site.name | smartify | jsonify }},
{% endif %}
{% if site.description %}
"description": {{ site.description | jsonify }},
{% endif %}
"home_page_url": {{ '/' | absolute_url | jsonify }},
"feed_url": {{ page.url | absolute_url | jsonify }},
{% if site.author %}
"author": {
"name": {{ site.author.name | default: site.author | jsonify }}
{% if site.author.uri %}
, "url": {{ site.author.uri | jsonify }}
{% endif %}
{% if site.author.avatar %}
, "avatar": {{ site.author.avatar | jsonify }}
{% endif %}
},
{% endif %}
"items": [
{% assign posts = site.posts | where_exp: "post", "post.draft != true" %}
{% for post in posts limit: 20 %}
{
"id": {{ post.id | absolute_url | jsonify }},
"url": {{ post.url | absolute_url | jsonify }},
"title": {{ post.title | smartify | strip_html | normalize_whitespace | jsonify }},
"content_html": {{ post.content | strip | jsonify }},
{% if post.excerpt and post.excerpt != empty %}
"summary": {{ post.excerpt | strip_html | normalize_whitespace | jsonify }},
{% endif %}
{% assign post_image = post.image.path | default: post.image %}
{% if post_image %}
{% unless post_image contains "://" %}
{% assign post_image = post_image | absolute_url | xml_escape %}
{% endunless %}
"image": {{ post_image | jsonify }},
{% endif %}
{% assign post_banner_image = post.banner_image.path | default: post.banner_image %}
{% if post_banner_image %}
"banner_image": {{ post_banner_image | jsonify }},
{% endif %}
"date_published": "{{ post.date | date_to_xmlschema }}",
"date_modified": "{{ post.last_modified_at | default: post.date | date_to_xmlschema }}",
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
{% assign post_author = site.data.authors[post_author] | default: post_author %}
{% assign post_author_uri = post_author.uri | default: nil %}
{% assign post_author_name = post_author.name | default: post_author %}
"author": {
"name": {{ post_author_name | default: "" | jsonify }}
{% if post_author_uri != nil %}
, "url": {{ post_author_uri | jsonify }}
{% endif %}
},
"tags": {{ post.tags | jsonify }}
}{% unless forloop.last == true %},{% endunless %}
{% endfor %}
]
}

66
feed.photos.json Normal file
View File

@ -0,0 +1,66 @@
---
layout:
---
{
"version": "https://jsonfeed.org/version/1",
{% if site.title %}
"title": {{ site.title | smartify | jsonify }},
{% elsif site.name %}
"title": {{ site.name | smartify | jsonify }},
{% endif %}
{% if site.description %}
"description": {{ site.description | jsonify }},
{% endif %}
"home_page_url": {{ '/' | absolute_url | jsonify }},
"feed_url": {{ page.url | absolute_url | jsonify }},
{% if site.author %}
"author": {
"name": {{ site.author.name | default: site.author | jsonify }}
{% if site.author.uri %}
, "url": {{ site.author.uri | jsonify }}
{% endif %}
{% if site.author.avatar %}
, "avatar": {{ site.author.avatar | jsonify }}
{% endif %}
},
{% endif %}
"items": [
{% assign posts = site.posts | where_exp: "post", "post.draft != true" %}
{% for post in site.categories.photos limit: 20 %}
{
"id": {{ post.id | absolute_url | jsonify }},
"url": {{ post.url | absolute_url | jsonify }},
"title": {{ post.title | smartify | strip_html | normalize_whitespace | jsonify }},
"content_html": {{ post.content | strip | jsonify }},
{% if post.excerpt and post.excerpt != empty %}
"summary": {{ post.excerpt | strip_html | normalize_whitespace | jsonify }},
{% endif %}
{% assign post_image = post.image.path | default: post.image %}
{% if post_image %}
{% unless post_image contains "://" %}
{% assign post_image = post_image | absolute_url | xml_escape %}
{% endunless %}
"image": {{ post_image | jsonify }},
{% endif %}
{% assign post_banner_image = post.banner_image.path | default: post.banner_image %}
{% if post_banner_image %}
"banner_image": {{ post_banner_image | jsonify }},
{% endif %}
"date_published": "{{ post.date | date_to_xmlschema }}",
"date_modified": "{{ post.last_modified_at | default: post.date | date_to_xmlschema }}",
{% assign post_author = post.author | default: post.authors[0] | default: site.author %}
{% assign post_author = site.data.authors[post_author] | default: post_author %}
{% assign post_author_uri = post_author.uri | default: nil %}
{% assign post_author_name = post_author.name | default: post_author %}
"author": {
"name": {{ post_author_name | default: "" | jsonify }}
{% if post_author_uri != nil %}
, "url": {{ post_author_uri | jsonify }}
{% endif %}
},
"tags": {{ post.tags | jsonify }}
}{% unless forloop.last == true %},{% endunless %}
{% endfor %}
]
}

27
feed.photos.xml Normal file
View File

@ -0,0 +1,27 @@
---
layout:
---
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[{{ site.title }}]]></title>
<link href="{{ site.url }}/atom.xml" rel="self"/>
<link href="{{ site.url }}/"/>
<updated>{{ site.time | date_to_xmlschema }}</updated>
<id>{{ site.url }}/</id>
<author>
<name><![CDATA[{{ site.author | strip_html }}]]></name>
{% if site.email %}<email><![CDATA[{{ site.email }}]]></email>{% endif %}
</author>
<generator uri="http://octopress.org/">Octopress</generator>
{% for post in site.categories.photos limit: 20 %}
<entry>
<title type="html"><![CDATA[{{ post.title | cdata_escape }}]]></title>
<link href="{{ site.url }}{{ post.url }}"/>
<updated>{{ post.date | date_to_xmlschema }}</updated>
<id>{{ site.url }}{{ post.id }}</id>
<content type="html"><![CDATA[{{ post.content | expand_urls: site.url | cdata_escape }}]]></content>
</entry>
{% endfor %}
</feed>

View File

@ -4,7 +4,6 @@ layout:
<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title><![CDATA[{{ site.title }}]]></title>
<link href="{{ site.url }}/atom.xml" rel="self"/>
<link href="{{ site.url }}/"/>