Skip to content

Commit d9a38af

Browse files
author
Derek Greer
committed
feat: Add syndication of author feeds.
This feature adds the ability to syndicate content from other feeds. This requires configuration in _config.yml, the author's index.html, and modification of the site's feed.informer.com aggregated feed.
1 parent 494dd9e commit d9a38af

26 files changed

+562
-164
lines changed

_config.yml

+8-1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ collections:
123123
author: "Jasdeep Singh"
124124
output: true
125125
permalink: /:collection/:year/:month/:day/:title/
126+
jasonmeridth:
127+
active: true
128+
author: "Jason Meridth"
129+
output: true
130+
permalink: /:collection/:year/:month/:day/:title/
131+
feed: "https://blog.jasonmeridth.com/feed.xml"
126132
jimmybogard:
127133
active: true
128134
author: "Jimmy Bogard"
@@ -131,6 +137,8 @@ collections:
131137
disqus:
132138
short_name: "jimmybogardblog"
133139
active: true
140+
post-prefix: "https://jimmybogard.com"
141+
feed: "http://feeds.feedburner.com/GrabBagOfT"
134142
joeocampo:
135143
active: false
136144
author: "Joe Ocampo"
@@ -255,7 +263,6 @@ theme: minima
255263
plugins:
256264
- jekyll-redirect-from
257265
- jekyll-gist
258-
#- jekyll-feed
259266

260267
JB:
261268
comments:

_includes/aggregate_post_scripts.html

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<!-- aggregate_post_scripts.html -->
2+
<script src="{{ site.baseurl }}/assets/js/feednami-client-v1.1.js"></script>
3+
<script src="{{ site.baseurl }}/assets/js/aggregate.js"></script>
4+
<script>
5+
loadPost('post');
6+
</script>

_includes/home_scripts.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<!-- home_scripts.html -->
2+
3+
<!-- js -->
4+
<script src="{{ site.baseurl }}/assets/js/feednami-client-v1.1.js"></script>
5+
<script src="{{ site.baseurl }}/assets/js/load-aggregate-posts.js"></script>
6+
<script>
7+
loadAggregatePosts('aggregate-posts');
8+
</script>

_includes/post_scripts.html

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<!-- post_scripts.html -->

_jasonmeridth/index.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
layout: author_default
3+
permalink: /jasonmeridth/index.html
4+
index: true
5+
syndicated: true
6+
redirect_from:
7+
- "/members/jason_meridth/default.aspx/"
8+
- "/blogs/jason_meridth/"
9+
---
10+
11+
<ul id="posts"/>
12+
13+
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>

_jimmybogard/index.html

+2-3
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
layout: author_default
33
permalink: /jimmybogard/index.html
44
index: true
5+
syndicated: true
56
redirect_from:
67
- "/members/jimmy_bogard/default.aspx/"
78
- "/blogs/jimmy_bogard/"
89
---
910

10-
<ul class="posts">
11-
{% include author_posts.html %}
12-
</ul>
11+
<ul id="posts"/>
1312

1413
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>

_layouts/aggregate_post.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
layout: author_default
3+
scripts: aggregate_post_scripts.html
4+
---
5+
<div class="box">
6+
<span class="post-text">{{ content }}</span>
7+
</div>

_layouts/author_default.html

+51-6
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<div class="tile is-4 is-child">
7575
<div class="tile is-parent is-vertical sidebar">
7676

77-
<div class="tile is-child widget">
77+
<div id="recentAuthorPostsContainer" class="tile is-child widget">
7878
<div class="card">
7979
<header class="card-header">
8080
<p class="card-header-title nice-title">
@@ -114,12 +114,57 @@
114114

115115
{% include footer.html %}
116116

117-
<!-- js -->
118-
<script type="text/javascript">
119-
var page_collection = "{{page.collection}}";
117+
118+
<script src="{{ site.baseurl }}/assets/js/feednami-client-v1.1.js"></script>
119+
<script src="{{ site.baseurl }}/assets/js/nav.js"></script>
120+
<script src="{{ site.baseurl }}/assets/js/search.js"></script>
121+
<script src="{{ site.baseurl }}/assets/js/load-authors.js"></script>
122+
{% if page.syndicated == true %}
123+
<script src="{{ site.baseurl }}/assets/js/load-aggregate-posts.js"></script>
124+
{% endif %}
125+
<script src="{{ site.baseurl }}/assets/js/load-recent-posts.js"></script>
126+
<script src="{{ site.baseurl }}/assets/js/load-recent-author-posts.js"></script>
127+
<script>
128+
var collections = [
129+
{% assign filtered_collections = ''|split:'' %}
130+
{% assign unfiltered_collections = site.collections %}
131+
{% for c in unfiltered_collections %}
132+
{% if c.label != "posts" %}
133+
{% assign filtered_collections = filtered_collections|push:c %}
134+
{% endif %}
135+
{% endfor %}
136+
{% for collection in filtered_collections %}
137+
{% assign label = collection.label %}
138+
{
139+
"label": "{{label}}",
140+
"url": "{{site.baseurl}}/{{label}}",
141+
"name": "{{collection.author}}",
142+
"postPrefix": "{{collection.post-prefix}}",
143+
"feed": "{{collection.feed}}"
144+
} {% if forloop.last %}{% else %},{% endif %}
145+
{% endfor %}
146+
];
147+
148+
{% assign col = site.collections | where: 'label', page.collection | first %}
149+
var page_collection = "{{page.collection}}";
150+
var collectionFeed = "{{col.feed}}";
151+
var collection = collections.find(function(col) {
152+
return col.label === "{{col.label}}";
153+
});
154+
155+
{% if page.syndicated == true %}
156+
loadAggregatePosts("posts", collectionFeed, true, collection);
157+
{% endif %}
158+
loadAuthors("authors");
159+
loadRecentPosts("recentPosts");
160+
loadRecentAuthorPosts("recentAuthorPosts", "recentAuthorPostsContainer");
120161
</script>
121-
<script src="{{ site.baseurl }}/assets/js/custom.js"></script>
122-
<script src="{{ site.baseurl }}/assets/js/typewriter.js"></script>
162+
163+
<!-- page scripts -->
164+
{% if layout.scripts %}
165+
{% include {{layout.scripts}} %}
166+
{% endif %}
167+
123168
</body>
124169
</html>
125170

_layouts/default.html

+32-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,39 @@
5353
</div>
5454

5555
{% include footer.html %}
56+
{% if layout.scripts %}
57+
{% include {{layout.scripts}} %}
58+
{% endif %}
5659

5760
<!-- js -->
58-
<script src="{{ site.baseurl }}/assets/js/custom.js"></script>
59-
<script src="{{ site.baseurl }}/assets/js/typewriter.js"></script>
61+
<script src="{{ site.baseurl }}/assets/js/nav.js"></script>
62+
<script src="{{ site.baseurl }}/assets/js/search.js"></script>
63+
<script src="{{ site.baseurl }}/assets/js/load-authors.js"></script>
64+
<script src="{{ site.baseurl }}/assets/js/load-recent-posts.js"></script>
65+
<script>
66+
var collections = [
67+
{% assign filtered_collections = ''|split:''%}
68+
{% assign unfiltered_collections = site.collections %}
69+
{% for c in unfiltered_collections %}
70+
{% if c.label != "posts" %}
71+
{% assign filtered_collections = filtered_collections|push:c%}
72+
{% endif %}
73+
{% endfor %}
74+
{% for collection in filtered_collections %}
75+
{% assign label = collection.label %}
76+
{
77+
"url": "{{site.baseurl}}/{{label}}",
78+
"name": "{{collection.author}}",
79+
"postPrefix": "{{collection.post-prefix}}",
80+
"feed": "{{collection.feed}}"
81+
} {% if forloop.last %}{% else %},{% endif %}
82+
{% endfor %}
83+
];
84+
85+
86+
loadAuthors("authors");
87+
loadRecentPosts("recentPosts");
88+
</script>
6089
</body>
6190
</html>
91+

_layouts/home.html

+5-24
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,17 @@
11
---
22
layout: default
3+
scripts: home_scripts.html
34
---
45

56
<div class="home">
67

78
{{ content }}
89

9-
<ul class="posts">
10-
{% assign author_posts = ''|split:''%}
11-
{% assign unfiltered_posts = site.documents %}
12-
{% for post in unfiltered_posts %}
13-
{% if post.index != true %}
14-
{% assign author_posts = author_posts|push:post%}
15-
{% endif %}
16-
{% endfor %}
10+
<ul class="posts">
11+
<div id="aggregate-posts"><img style="display:block; margin: auto;" src="{{site.baseurl}}/assets/images/spinner.gif"/></div>
12+
</ul>
1713

18-
{% assign posts = author_posts | sort: 'date' | reverse %}
19-
{% for post in posts limit: 10 %}
20-
21-
<div class="box">
22-
<h1 class="post-title">
23-
<a style="color:#4a4a4a;" href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
24-
</h1>
25-
<span class="post-meta">{{ post.date | date: "%-d %B, %Y. It was a %A." }} <a style="color:grey" href="{{ site.baseurl }}{{ post.url }}"></a></span><hr/>
26-
27-
<span class="post-text">{{ post.content }}</span>
28-
</div>
29-
30-
{% endfor %}
31-
</ul>
32-
33-
<p class="rss-subscribe">subscribe <a href="{{ "/feed.xml" | relative_url }}">via RSS</a></p>
14+
<p class="rss-subscribe">subscribe <a href="{{ site.feed }}">via RSS</a></p>
3415

3516
</div>
3617

_layouts/post.html

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
layout: author_default
3+
scripts: post_scripts.html
34
---
45

56
<div class="box">
@@ -31,10 +32,6 @@ <h1 class="post-title">{{ page.title }}</h1>
3132
{%endif%}
3233
</div>
3334

34-
<!--<div class="box">-->
35-
<!-- google ads code box -->
36-
<!--</div>-->
37-
3835
{% assign col = site.collections | where: 'label', page.collection | first%}
3936
{% if col.disqus.active == true %}
4037

assets/images/2387303.PDF

166 KB
Binary file not shown.

assets/images/external-link.png

19.2 KB
Loading

assets/images/spinner.gif

11.5 KB
Loading

assets/js/aggregate.js

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
layout: null
3+
---
4+
function getParameterByName(name, url) {
5+
if (!url) url = window.location.href;
6+
name = name.replace(/[\[\]]/g, "\\$&");
7+
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
8+
results = regex.exec(url);
9+
if (!results) return null;
10+
if (!results[2]) return '';
11+
return decodeURIComponent(results[2].replace(/\+/g, " "));
12+
}
13+
14+
function loadPost(id) {
15+
const postDiv = document.getElementById(id);
16+
var url = "http://feed.informer.com/digests/ZWDBOR7GBI/feeder.rss";
17+
var feed = getParameterByName('feed');
18+
19+
if(feed) {
20+
url = feed;
21+
}
22+
23+
feednami.load(url,function(result){
24+
if(result.error) {
25+
console.log(result.error);
26+
} else {
27+
28+
let posts = result.feed.entries;
29+
var guid = getParameterByName('guid');
30+
31+
var post = posts.find(function(post) {
32+
return post.guid === guid;
33+
});
34+
35+
let box = createNode('div');
36+
let external = createNode('div');
37+
let externalImage = createNode('img');
38+
let externalLink = createNode('a');
39+
let titleHeading = createNode('h1');
40+
let titleLink = createNode('a');
41+
let titleText = createNode('span');
42+
let summary = createNode('span');
43+
let metadata = createNode('span');
44+
45+
//box.classList.add("box");
46+
47+
if(!post.link.startsWith("{{site.baseurl}}")) {
48+
external.style.color = "blue";
49+
external.style.position = "relative";
50+
external.style.float = "right";
51+
external.style.top = "-8px";
52+
external.style.right = "-8px";
53+
externalLink.href = post.link;
54+
externalImage.setAttribute('src', "{{site.baseurl}}/assets/images/external-link.png");
55+
externalImage.style.width = "14px";
56+
externalImage.style.height = "14px";
57+
58+
append(externalLink, externalImage);
59+
append(external, externalLink);
60+
append(box, external);
61+
}
62+
63+
titleHeading.classList.add("post-title");
64+
titleLink.href=post.link;
65+
titleText.innerHTML = `${post.title}`;
66+
titleLink.style.color = "#4a4a4a";
67+
append(titleLink, titleText);
68+
append(titleHeading, titleLink);
69+
append(box, titleHeading);
70+
71+
metadata.innerHTML = `<span class="post-meta">getAuthor(post) - ${new Date(post.date).toLocaleString()} <a style="color:grey" href=${post.link}></a></span><hr/>`;
72+
append(box, metadata);
73+
74+
summary.classList.add("post-text");
75+
summary.innerHTML = getContent(post);
76+
append(box, summary);
77+
postDiv.innerHTML = null;
78+
append(postDiv, box);
79+
}
80+
});
81+
}
82+
83+
function getContent(post) {
84+
var content = null;
85+
86+
if(post["content:encoded"] && post["content:encoded"]["#"]) {
87+
return post["content:encoded"]["#"];
88+
}else if(post["atom:content"] && post["atom:content"]["#"]) {
89+
return post["atom:content"]["#"];
90+
}
91+
92+
return `${post.summary} <a href=${post.link}>Continue Reading ...</a>`;
93+
}
94+
95+
function getAuthor(post) {
96+
return post.author || post.source.title;
97+
}
98+
99+
100+
function createNode(element) {
101+
return document.createElement(element);
102+
}
103+
104+
function append(parent, el) {
105+
return parent.appendChild(el);
106+
}
107+

0 commit comments

Comments
 (0)