Skip to content

Commit

Permalink
Support Atom feed
Browse files Browse the repository at this point in the history
  • Loading branch information
KawaiiZapic committed Nov 18, 2020
1 parent 34bd016 commit 215a5fc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion static/css/loading.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Present by Zapic @ 2020
* https://github.com/KawaiiZapic/Present/
*
* Please DO NOT remove this copyright message, as the basic respect for origin author.
* Please DO NOT remove this copyright message, as the basic respect for original author.
*
*/

Expand Down
2 changes: 1 addition & 1 deletion static/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Present by Zapic @ 2020
* https://github.com/KawaiiZapic/Present/
*
* Please DO NOT remove this copyright message, as the basic respect for origin author.
* Please DO NOT remove this copyright message, as the basic respect for original author.
*
*/

Expand Down
28 changes: 19 additions & 9 deletions static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Present by Zapic @ 2020
* https://github.com/KawaiiZapic/Present/
*
* Please DO NOT remove this copyright message, as the basic respect for origin author.
* Please DO NOT remove this copyright message, as the basic respect for original author.
*
*/

Expand Down Expand Up @@ -69,16 +69,26 @@ feed.addEventListener("load", function () {
if(!xml){
throw new Error();
}
xml = xml.querySelectorAll("channel item");
var data = [];
xml.forEach(function (v,i){
if(i > 7){ return; }
data.push({
"link": v.querySelector("link").innerHTML,
"timestamp": dateParser(v.querySelector("pubDate").innerHTML),
"title": v.querySelector("title").innerHTML
if(xml.querySelector("rss") != null){
xml.querySelectorAll("channel item").forEach(function (v,i){
if(i > 7){ return; }
data.push({
"link": v.querySelector("link").innerHTML,
"timestamp": dateParser(v.querySelector("pubDate").innerHTML),
"title": v.querySelector("title").innerHTML
});
});
});
} else if(xml.querySelector("feed") != null) {
xml.querySelectorAll("feed entry").forEach(function (v,i){
if(i > 7){ return; }
data.push({
"link": v.querySelector("link").href,
"timestamp": dateParser(v.querySelector("published").innerHTML),
"title": v.querySelector("title").innerHTML
});
});
}
}
} catch (e) {
setArtTip('<i class="fa fa-warning"></i><p class="article-empty-tip">暂时无法连接到博客</p>');
Expand Down

0 comments on commit 215a5fc

Please sign in to comment.