summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--feed.json155
-rw-r--r--feed.xslt.xml13
-rw-r--r--rss.xml6
3 files changed, 62 insertions, 112 deletions
diff --git a/feed.json b/feed.json
index d286302..f21c783 100644
--- a/feed.json
+++ b/feed.json
@@ -1,106 +1,59 @@
 ---
-layout: null
 ---
-{% capture cache %}
-  {% assign feed = site.data.json_feed | default: site.json_feed %}
-  {% assign title = site.title | smartify | jsonify %}
-  {% assign home_page_url = "/" | absolute_url %}
-  {% assign feed_url = "/feed.json" | absolute_url %}
-  {% assign description = site.description | smartify | jsonify %}
-  {% assign author_name = feed.author.name | default: site.author | default: "" %}
-  {% assign local_avatar_url = feed.author.avatar.local_path | absolute_url %}
-  {% assign avatar_url = feed.author.avatar.external_url | default: local_avatar_url %}
-  {% assign hubs = feed.hubs %}
-  {% assign post_limit = feed.post_limit | default: 20 %}
-{% endcapture %}{% assign cache = nil %}
 {
-  "version": "https://jsonfeed.org/version/1",
-  "title": {{ title }},
-  "home_page_url": "{{ home_page_url }}",
-  "feed_url": "{{ feed_url }}",
-  "description": {{ description }},{% if feed.icon %}
-  "icon": "{{ "/" | append: feed.icon | absolute_url }}",{% endif %}{% if feed.favicon %}
-  "favicon": "{{ "/" | append: feed.favicon | absolute_url }}",{% endif %}{% if feed.user_comment %}
-  "user_comment": "{{ feed.user_comment }}",{% endif %}{% if feed.author %}
-  "author": {
-    "name": "{{ author_name }}"{% if feed.author.url %},
-    "url": "{{ feed.author.url }}"{% endif %}{% if avatar_url %},
-    "avatar": "{{ avatar_url }}"{% endif %}
-  }{% endif %}{% if feed.expired %},
-  "expired": {{ feed.expired }}{% endif %}, {% if hubs %}
-  "hubs": [{% for hub in hubs %}{
-     "url": "{{ hub.url }}",
-     "type": "{{ hub.type }}"
-  }{% unless forloop.last %},{% endunless %}{% endfor %}],{% endif %}
-  "items": [
-    {% for post in site.posts limit: post_limit %}{
-      {% capture cache %}
-      {% assign post_json_feed = post.json_feed  %}
-      {% assign title = post.title | smartify | jsonify %}
-      {% assign unique_url = site.url | append: post.id %}
-      {% assign external_url = post.external_url  %}
-      {% assign date_published = post.date | date_to_xmlschema %}
-      {% if post_json_feed.date_modified %}
-        {% assign date_modified = post_json_feed.date_modified | date_to_xmlschema %}
-      {% endif %}
-
-      {% assign publish_as_text = post_json_feed.publish_as_text %}
-
-      {% if publish_as_text %}
-        {% assign content_key = "content_text" %}
-        {% assign content = post.content | expand_urls: site.url | strip_html | jsonify %}
-      {% else %}
-        {% assign content_key = "content_html" %}
-        {% assign content = post.content | expand_urls: site.url | jsonify %}
-      {% endif %}
-
-      {% assign summary =  post_json_feed.summary | default: post.summary | default: post.excerpt |  default: post.description %}
-
-      {% assign local_image_url = post_json_feed.image.local_path | absolute_url %}
-      {% assign image_url = post_json_feed.image.external_url | default: local_image_url | default: post.thumbnail | default: post.image %}
-
-      {% assign local_banner_image_url = post_json_feed.banner_image.local_path | absolute_url %}
-      {% assign banner_image_url = post_json_feed.banner_image.external_url | default: local_banner_image_url | default: post.banner_image %}
-
-      {% assign post_author = post_json_feed.author  %}
-      {% assign post_author_name = post_author.name %}
-      {% assign post_author_url = post_author.url %}
-      {% assign post_local_avatar_url = post_author.avatar.local_path | absolute_url %}
-      {% assign post_avatar_url = post_author.avatar.external_url | default: post_local_avatar_url %}
-
-      {% if feed.use_category_as_tag %}
-        {% assign tags = post.category | jsonify %}
-      {% else %}
-        {% assign tags = post.tags | jsonify %}
-      {% endif %}
-
-      {% assign attachments = post_json_feed.attachments %}
-
-      {% endcapture %}{% assign cache = nil %}
-      "id": "{{ unique_url }}",
-      "url": "{{ unique_url }}",{% if external_url %}
-      "external_url": {{ external_url }},{% endif %}{% if title %}
-      "title": {{ title }},{% endif %}
-      "date_published": "{{ date_published }}",{% if date_modified %}
-      "date_modified": "{{ date_modified }}",{% endif %}{% if summary %}
-      "summary": "{{ summary }}",{% endif %}{% if image_url %}
-      "image": "{{ image_url }}",{% endif %}{% if banner_image_url %}
-      "banner_image": "{{ banner_image_url }}",{% endif %}{% if post_author %}
-      "author": {
-        "name": "{{ post_author_name }}"{% if post_author_url %},
-        "url": "{{ post_author_url }}"{% endif %}{% if post_avatar_url %},
-        "avatar": "{{ post_avatar_url }}"{% endif %}
-      },{% endif %} {% if tags %}
-      "tags": {{ tags }},{% endif %} {% if attachments %}
-      "attachments": [{% for attachment in attachments %}{
-        "url": "{{ attachment.url }}",{% if attachment.title %}
-        "title": "{{ attachment.title }}",{% endif %} {% if attachment.size_in_bytes %}
-        "size_in_bytes": "{{ attachment.size_in_bytes }}",{% endif %} {% if attachment.duration_in_seconds %}
-        "duration_in_seconds": "{{ attachment.duration_in_seconds }}",{% endif %}
-        "mime_type": "{{ attachment.mime_type }}"
-      }{% unless forloop.last %},{% endunless %}{% endfor %}],{% endif %}
-      "{{ content_key }}": {{ content }}
-    }{% unless forloop.last %},{% endunless %}
+    "version": "https://jsonfeed.org/version/1",
+    "title": "{{ site.title | xml_escape }}",
+    "home_page_url": "{{ "/" | absolute_url }}",
+    "feed_url": "{{ "/feed.json" | absolute_url }}",
+    "description": {{ site.description | jsonify }},
+    "favicon": "{{ "/favicon.ico" | absolute_url }}",
+    "expired": false,
+    {% if site.author %}
+    "author": {% if site.author.name %} {
+        "name": "{{ site.author.name }}",
+        "url": {% if site.author.url %}"{{ site.author.url }}"{% else %}null{% endif %},
+        "avatar": {% if site.author.avatar %}"{{ site.author.avatar }}"{% else %}null{% endif %}
+    },{% else %}"{{ site.author }}",{% endif %}
+    {% endif %}
+    "items": [
+    {% for post in site.posts limit:10 %}
+        {
+            "id": "{{ post.url | absolute_url }}",
+            "title": {{ post.title | jsonify }},
+            "summary": {{ post.excerpt | strip_html | jsonify }},
+            "content_text": {{ post.content | strip_html | strip_newlines | jsonify }},
+            "content_html": {{ post.content | strip_newlines | jsonify }},
+            "url": "{{ post.url | absolute_url }}",
+            {% if post.image.size > 1 %}"image": {{ post.image | jsonify }},{% endif %}
+            {% if post.link.size > 1 %}"external_url": "{{ post.link }}",{% endif %}
+            {% if post.banner.size > 1 %}"banner_image": "{{ post.banner }}",{% endif %}
+            {% if post.tags.size > 1 %}"tags": {{ post.tags | jsonify }},{% endif %}
+            {% if post.enclosure.size > 1 %}"attachments": [
+            {
+              "url": "{{ post.enclosure }}",
+              "mime_type": "{{ post.enclosure_type }}",
+              "size_in_bytes": "{{ post.enclosure_length }}"
+            },{% endif %}
+            "date_published": "{{ post.date | date_to_xmlschema }}",
+            "date_modified": "{{ post.date | date_to_xmlschema }}",
+            {% if post.author %}
+                "author": {% if post.author.name %} {
+                "name": "{{ post.author.name }}",
+                "url": {% if post.author.url %}"{{ post.author.url }}"{% else %}null{% endif %},
+                "avatar": {% if post.author.avatar %}"{{ post.author.avatar }}"{% else %}null{% endif %}
+                }
+                {% else %}"{{ post.author }}"{% endif %}
+            {% else %}
+                "author": {% if site.author.name %} {
+                "name": "{{ site.author.name }}",
+                "url": {% if site.author.url %}"{{ site.author.url }}"{% else %}null{% endif %},
+                "avatar": {% if site.author.avatar %}"{{ site.author.avatar }}"{% else %}null{% endif %}
+                }
+                {% else %}
+                "{{ site.author }}"
+                {% endif %}
+            {% endif %}
+        }{% if forloop.last == false %},{% endif %}
     {% endfor %}
-  ]
+    ]
 }
\ No newline at end of file
diff --git a/feed.xslt.xml b/feed.xslt.xml
index 58e3109..db7e02e 100644
--- a/feed.xslt.xml
+++ b/feed.xslt.xml
@@ -22,8 +22,8 @@ https://nicolas-hoizey.com/feeds/all.xml
         <meta charset="utf-8"/>
         <meta name="viewport" content="width=device-width, initial-scale=1"/>
         <title>
-          Atom Feed |
-          <xsl:value-of select="/atom:feed/atom:title"/>
+          Web Feed |
+          <xsl:value-of select="/atom:feed/atom:title"/><xsl:value-of select="/rss/channel/title"/>
         </title>
         <style type="text/css">*{box-sizing:border-box}body{background-color:#fff;color:#24292e;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";line-height:1.5}a{color:#0366d6;text-decoration:none}a:hover{text-decoration:underline}.container{max-width:40rem;margin:1rem auto;padding:1rem}nav{margin-top:2rem;margin-bottom:2rem}p{margin-top:0;margin-bottom:1rem}h1,h2,h3{margin-top:0;margin-bottom:1rem;font-weight:600;line-height:1.25}h1{padding-bottom:.3em;font-size:2em}h1 svg{padding-right:.25rem;vertical-align:text-bottom;width:1.2em;height:1.2em}h2{margin-top:1.5rem;padding-bottom:.3em;font-size:1.5em;border-bottom:1px solid #eaecef}h3{font-size:1.25em;margin-bottom:0}.about{background-color:#fff5b1;margin:.25rem -.25rem;padding:.25rem}header{padding-top:2rem;padding-bottom:2rem}.item{padding-bottom:2rem}.gray{color:#586069}</style>
       </head>
@@ -57,13 +57,10 @@ https://nicolas-hoizey.com/feeds/all.xml
               </svg>
               Web Feed Preview
             </h1>
-            <h2><xsl:value-of select="atom:feed/atom:title"/></h2>
-            <p><xsl:value-of select="atom:feed/atom:description"/></p>
+            <h2><xsl:value-of select="atom:feed/atom:title"/><xsl:value-of select="/rss/channel/title"/></h2>
+            <p><xsl:value-of select="atom:feed/atom:description"/><xsl:value-of select="/rss/channel/description"/></p>
             <p>This preview only shows titles and summaries, but the actual feed(Atom) contains the full content.</p>
-            <a>
-              <xsl:attribute name="href">
-                <xsl:value-of select="/atom:feed/atom:link[2]/@href"/>
-              </xsl:attribute>
+            <a href="/">
               Visit Website &#x2192;
             </a>
           </header>
diff --git a/rss.xml b/rss.xml
index 2af6378..84815bf 100644
--- a/rss.xml
+++ b/rss.xml
@@ -4,16 +4,16 @@
 <?xml-stylesheet type="text/xml" href="/feed.xslt.xml"?>
 <rss version="2.0">
 	<channel>
-		<title>{{ site.name | xml_escape }}</title>
+		<title>{{ site.title | xml_escape }}</title>
 		<description>{% if site.description %}{{ site.description | xml_escape }}{% endif %}</description>		
-		<link>{{ site.url }}</link>
+		<link>"{{ "/" | absolute_url }}"</link>
 		<lastBuildDate>{{ site.time | date_to_rfc822 }}</lastBuildDate>
         <language>{{ site.lang | default: "zh-CN" }}</language>
 		{% for post in site.posts limit:10 %}
 			<item>
 				<title>{{ post.title | xml_escape }}</title>
 				{% if post.excerpt %}
-					<description>{{ post.excerpt | xml_escape }}</description>
+					<description>{{ post.excerpt | strip_html | xml_escape }}</description>
 				{% else %}
 					<description>{{ post.content | xml_escape }}</description>
 				{% endif %}