mirror of
https://github.com/SouthFox-D/SouthFox-D.github.io.git
synced 2024-11-29 01:55:19 +01:00
feat: Enable foxsay
This commit is contained in:
parent
b604e5ee14
commit
b9085ba8fa
5 changed files with 46 additions and 94 deletions
|
@ -3,21 +3,11 @@ title: 狐说
|
|||
date: 2021-07-11 17:45:57
|
||||
---
|
||||
|
||||
<html>
|
||||
<link rel="stylesheet" href="/css/foxsay.css" media="screen" type="text/css">
|
||||
<main id="app">
|
||||
<aside>
|
||||
</aside>
|
||||
<section class="item" v-for="item in contents" v-cloak>
|
||||
<bb v-html='item.attributes.content'></bb>
|
||||
<time v-html:datetime="item.attributes.time">{{item.attributes.time}}</time>
|
||||
</section>
|
||||
<div class="load-ctn">
|
||||
<button class="btn btn-default " v-on:click="loadMore" v-if="contents" v-cloak>加载更多</button>
|
||||
<p class="tip" v-else>加载中……</p>
|
||||
</div>
|
||||
</main>
|
||||
<script src="https://cdn.bootcss.com/vue/2.6.11/vue.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/leancloud-storage@4.5.3/dist/av-min.js"></script>
|
||||
<main id='app'>
|
||||
<div id="foxsay">
|
||||
</div>
|
||||
<center><a target="_blank" href="https://foxsay.southfox.me/@SouthFox" type="button" class="btn btn-default"><i class="fa fa-paw"></i>到原始站点查看</a></center>
|
||||
</main>
|
||||
<script src="../js/rss-parser.min.js"></script>
|
||||
<script src="../js/foxsay.js"></script>
|
||||
</html>
|
|
@ -23,6 +23,9 @@ menu:
|
|||
- title: 友链
|
||||
url: friends
|
||||
intro: "朋友们"
|
||||
- title: 狐说
|
||||
url: foxsay
|
||||
intro: "狐狸怎么叫?"
|
||||
- title : 开往
|
||||
url: travellings
|
||||
intro: "一群狼走得更远"
|
||||
|
@ -40,6 +43,10 @@ links:
|
|||
url: /rss2.xml
|
||||
intro: "Subscribe me."
|
||||
icon: "fas fa-rss"
|
||||
- title: Foxsay
|
||||
url: /foxsay
|
||||
intro: "OWO"
|
||||
icon: "fa fa-paw"
|
||||
- title: 开往
|
||||
url: https://travellings.link
|
||||
intro: "一群狼走得更远"
|
||||
|
|
|
@ -31,10 +31,6 @@
|
|||
display: none;
|
||||
}
|
||||
|
||||
body,
|
||||
button {
|
||||
font-family: 'Noto Serif SC', serif;
|
||||
}
|
||||
|
||||
aside {
|
||||
font-weight: 300;
|
||||
|
@ -60,11 +56,15 @@ footer {
|
|||
font-weight: 300;
|
||||
font-style: normal;
|
||||
line-height: 1.8rem;
|
||||
background: #000;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 1px 6px rgba(32, 33, 36, 0.28);
|
||||
margin-top: 20px;
|
||||
border-top-color: coral !important;
|
||||
border-top: 6px solid;
|
||||
text-align: justify;
|
||||
background: #000;
|
||||
white-space: pre-line;
|
||||
}
|
||||
|
||||
.item a {
|
||||
|
@ -77,17 +77,3 @@ time {
|
|||
color: #bbb;
|
||||
font-size: 15px;
|
||||
}
|
||||
|
||||
bb {
|
||||
font-family: 'Noto Serif SC', serif;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.center-text {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.load-ctn {
|
||||
margin-top: 15px;
|
||||
width: 100%;
|
||||
}
|
|
@ -1,60 +1,19 @@
|
|||
var {
|
||||
Query
|
||||
} = AV;
|
||||
AV.init({
|
||||
appId: "hINvYWepO1gnhcNIPEycw7o5-MdYXbMMI", //你的 leancloud 应用 id (设置-应用keys-AppID)
|
||||
appKey: "9PFMoeAb7yW62fAyNYdVDHAQ", //你的 leancloud 应用 AppKey (设置-应用keys-AppKey)
|
||||
});
|
||||
let parser = new RSSParser();
|
||||
parser.parseURL('https://foxsay.southfox.me/@SouthFox.rss', function(err, feed) {
|
||||
if (err) throw err;
|
||||
for (let i = 0; i < 10; i++) {
|
||||
const entry = feed.items[i];
|
||||
printPost(entry);
|
||||
}
|
||||
});
|
||||
|
||||
var query = new AV.Query('content');
|
||||
function printPost(entry) {
|
||||
section = document.createElement("section");
|
||||
section.classList.add('item');
|
||||
popContent = entry.contentSnippet;
|
||||
|
||||
var app = new Vue({
|
||||
el: '#app',
|
||||
data: {
|
||||
page: 0,
|
||||
count: 0,
|
||||
contents: []
|
||||
},
|
||||
methods: {
|
||||
loadMore: function(event) {
|
||||
getData(++this.page);
|
||||
}
|
||||
}
|
||||
})
|
||||
section.innerHTML = popContent;
|
||||
|
||||
function urlToLink(str) {
|
||||
var re = /(http|ftp|https):\/\/[\w-]+(.[\w-]+)+([\w-.,@?^=%&:/~+#]*[\w-\@?^=%&/~+#])?/g;;
|
||||
|
||||
str = str.replace(re, function(website) {
|
||||
if (str.indexOf("cf-ipfs") != -1 ) {
|
||||
return "<img src='" + website + "' alt='图片'></img>"
|
||||
} else {
|
||||
return "<a href='" + website + "' target='_blank'> <i class='iconfont icon-lianjie-copy'></i>链接 </a>";
|
||||
}
|
||||
});
|
||||
return str;
|
||||
}
|
||||
|
||||
function getData(page = 0) {
|
||||
query.descending('createdAt').skip(page * 20).limit(20).find().then(function(results) {
|
||||
if (results.length == 0) {
|
||||
alert('无了。')
|
||||
} else {
|
||||
let resC = results;
|
||||
reqData = false;
|
||||
resC.forEach((i) => {
|
||||
let dateTmp = new Date(i.createdAt);
|
||||
i.attributes.content = "<p>" + urlToLink(i.attributes.content) + "</p>";
|
||||
i.attributes.time = `${dateTmp.getFullYear()}-${(dateTmp.getMonth() + 1) < 10 ? ('0' + (dateTmp.getMonth()+1)) : dateTmp.getMonth()+1}-${(dateTmp.getDate() + 1) < 10 ? ('0' + dateTmp.getDate()) : dateTmp.getDate()} ${(dateTmp.getHours() + 1) <= 10 ? ('0' + dateTmp.getHours()) : dateTmp.getHours()}:${(dateTmp.getMinutes() + 1) <= 10 ? ('0' + dateTmp.getMinutes()) : dateTmp.getMinutes()}`;
|
||||
app.contents.push(i);
|
||||
})
|
||||
}
|
||||
|
||||
}, function(error) {});
|
||||
}
|
||||
|
||||
getData(0);
|
||||
|
||||
query.count().then(function(count) {
|
||||
app.count = count;
|
||||
}, function(error) {});
|
||||
blogs = document.getElementById('foxsay');
|
||||
blogs.append(section);
|
||||
}
|
||||
|
|
10
themes/freemind/source/js/rss-parser.min.js
vendored
Normal file
10
themes/freemind/source/js/rss-parser.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue