-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeed-atom.html
165 lines (144 loc) · 6.77 KB
/
feed-atom.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
---
layout: null
date_format: '%Y-%m-%dT%T%:z'
version: 0.0.1
license: AGPL-3.0
author: S0AndS0
---
{% capture workspace__feed_atom %}
{% assign collection_name = page.collection_name | default: include.collection_name | default: nil %}
{% assign target_collection = site[collection_name] %}
{% assign collection_content_type = page.content_type | default: target_collection.feeds.atom.content_type %}
{% unless this_repo %}
{% assign repo_name = site.github.repository_name %}
{% assign this_repo = site.github.public_repositories | where: "name", repo_name | first %}
{% endunless %}
{% assign this_time_stamp = page.date | date: '%s' %}
{% assign latest_time_stamp = page.date | date: '%s' %}
{% assign atom_entries_has_output = False %}
{% comment %}
Builds entries list from collection posts
{% endcomment %}
{% capture workspace__atom_entries %}
{% for post in target_collection %}
{% if page.relative_path == post.relative_path or post.slug == 'feed' %}
{% continue %}
{% elsif post.slug == collection_name or post.slug == 'index' %}
{% continue %}
{% endif %}
{% assign atom_entries_has_output = True %}
{% assign post_summary = post.description | default: post.excerpt %}
{% assign post_date_updated = post.date_updated | default: post.date %}
{% assign post_word_count = post_summary | append: post.content | number_of_words %}
{% assign post_content_type = post.content_type | default: collection_content_type %}
{% assign this_time_stamp = post_date_updated | date: '%s' %}
{% if latest_time_stamp < this_time_stamp %}
{% assign latest_time_stamp = this_time_stamp %}
{% endif %}
<entry>
<title>{{- post.title | xml_escape -}}</title>
<link rel="alternate" type="text/html" href="{{- post.url | absolute_url -}}" />
<id>urn:uuid:{{- this_repo.id -}}-{{- this_time_stamp -}}-{{- post_word_count -}}</id>
{% comment %}
<link href="{{- post.url | absolute_url -}}" />
{% endcomment %}
<published>{{- post.date | date: layout.date_format -}}</published>
<updated>{{- post_date_updated | date: layout.date_format -}}</updated>
<summary>{{- post_summary | xml_escape -}}</summary>
{% if post.author and post.author != page_author %}
<author>
<name>{{- post.author | xml_escape -}}</name>
{% if post.email %}
<email>{{- post.email -}}</email>
{% endif %}
{% if post.uri %}
<uri>{{- post.uri -}}</uri>
{% endif %}
</author>
{% endif %}
{% if post.contributors %}
{% capture contributors_workspace %}
{% for contributor in post.contributors %}
<contributor>
<name>{{ contributor | xml_escape }}</name>
</contributor>
{% endfor %}
{% endcapture %}{{ contributors_workspace | strip }}{% assign contributors = nil %}
{% endif %}
{% if post.content %}
{% if post_content_type != 'json' or post_content_type != 'xml' %}
{% capture post_content_data_string %}
xml:base="{{ site.url }}"
{% endcapture %}
{% endif %}
{% if post_content_type == 'xhtml' %}
<content type="xhtml" {{ post_content_data_string }}>
<div xmlns="http://www.w3.org/1999/xhtml">
{{ post.content | markdownify }}
</div>
</content>
{% elsif post_content_type == 'xml' %}
<content type="text/xml">
{{ post.content }}
</content>
{% elsif post_content_type == 'json' %}
<content type="text/json">
{{ post.content }}
</content>
{% elsif post_content_type %}
<content type="{{- post_content_type -}}" {{ post_content_data_string }}>
{{ post.content }}
</content>
{% else %}
<content type="html" {{ post_content_data_string }}>
<![CDATA[ {{ post.content | markdownify }} ]]>
</content>
{% endif %}
{% endif %}
</entry>{% comment %}<br>{% endcomment %}
{% assign post_date_updated = nil %}
{% assign post_content_type = nil %}
{% assign post_summary = nil %}
{% assign post_word_count = nil %}
{% assign post_content_data_string = nil %}
{% endfor %}
{% endcapture %}
{% assign collection_home = page.collection_home | default: target_collection.relative_directory %}
{% assign collection_home_page = site.pages | where: "url", collection_home | first %}
{% assign collection_home_summary = collection_home_page.description | default: collection_home_page.excerpt %}
{% assign collection_home_word_count = collection_home_summary | append: collection_home_page.content | number_of_words %}
{% assign page_author = page.author | default: site.author %}
{% assign page_email = page.email | default: site.email %}
{% assign page_title = page.title | default: collection_home.title | default: 'Atom Feed Title' %}
{% assign page_sub_title = page.sub_title | default: collection_home.sub_title | default: nil %}
{% assign page_rights = page.copy_right | default: collection_home.copy_right | default: site.copy_right %}
{% assign page_rights = page_rights | default: site.github.license.name | default: 'All rights reserved' %}
{% comment %}
Builds final output for collection feed data
{% endcomment %}
<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>{{ page_title | xml_escape }}</title>
{% if page_sub_title %}
<subtitle>{{ page_sub_title | xml_escape }}</subtitle>
{% endif %}
<rights>Copyright {{ site.time | date: '%Y' }} {{ page_author | xml_escape }}. {{ page_rights | xml_escape }}</rights>
<link href="{{- page.url | absolute_url -}}" rel="self" type="application/atom+xml" />
<link href="{{- collection_home | absolute_url -}}" />
<id>urn:uuid:{{- this_repo.id -}}-{{- latest_time_stamp -}}-{{- collection_home_word_count -}}</id>
{% if page_author %}
<author>
<name>{{ page_author | xml_escape }}</name>
{% if page_email %}<email>{{- page_email -}}</email>{% endif %}
</author>
{% endif %}
<updated>{{- latest_time_stamp | date: layout.date_format -}}</updated>
{% if atom_entries_has_output == True %}
{{- workspace__atom_entries | strip -}}{% assign workspace__atom_entries = nil %}
{% endif %}
</feed>
{% assign page_author = nil %}
{% assign page_email = nil %}
{% assign collection_home_summary = nil %}
{% assign collection_home_word_count = nil %}
{% endcapture %}{{- workspace__feed_atom | strip -}}{% assign workspace__feed_atom = nil %}