diff --git a/README.md b/README.md index e8fdeaa..0c2806d 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,39 @@ # Present -一个简洁的个人主页,支持显示博客文章. + +Present is present by Zapic. +一个简洁的个人主页,支持显示博客文章/随机背景图片/随机语句. +[即时预览](https://kawaiizapic.github.io/Present/) +![preview.png](https://i.loli.net/2020/11/15/ukl6jRxNm8O7bD2.png) + +### Browser support: +| IE | Chrome | Firefox | Other | +| ---- | ---- | ---- | ---- | +| 11+(Particle Support) | 49+ | 52+ | (?) | + +## Setting-up: + +### 随机背景图片 +1. 将图片放入`static/img/`内. +2. 建议放入一个图片的缩略图优化加载体验. +3. 在`index.html`内找到`var bgArr = [...` +4. 按以下格式添加一个对象: +``` +{ + "url": "static/img/background.jpg", + "thumb": "static/img/background-thumb.jpg" // 如果没有缩略图,可以留空. +} +``` +5. 如果不会可以简单的学一下`JavaScript`语法. + +### 随机语句 +1. 在`index.html`内找到`var senArr = [...` +2. 按照 [Typinyin.js](https://github.com/ClassicOldSong/typinyin.js) 的文档添加语句. +3. 如果不会可以简单的学一下`JavaScript`语法. + + +### 博客文章输出 +**注意:** 使用本功能,你的服务器必须支持`PHP 5.6+`,并启用`XML`拓展. + +1. 在`feed.php`内找到`$feed_url`; +2. 将`$feed_url`修改为你的博客RSS订阅地址. +3. 如果不会可以简单的学一下`PHP`语法. \ No newline at end of file diff --git a/feed.php b/feed.php new file mode 100644 index 0000000..f9848a1 --- /dev/null +++ b/feed.php @@ -0,0 +1,26 @@ +channel->item; +$resp = [ + "status" => 0, + "data" => [] +]; +if($data){ + for($i = 0; $i < 8; $i++){ + if($data[$i]){ + $resp["data"][]=[ + "link" => ((array)$data[$i]->link)[0], + "title" => ((array)$data[$i]->title)[0], + "timestamp" => date("Y-m-d",strtotime($data[$i]->pubDate[0])) + ]; + } + else{ + break; + } + } +} +else{ + $resp["status"] = -1; +} +header("Content-type: application/json"); +echo json_encode($resp); diff --git a/index.html b/index.html new file mode 100644 index 0000000..8f3517e --- /dev/null +++ b/index.html @@ -0,0 +1,125 @@ + + +
+ +Loading...
+Present
+ +暂时无法连接到博客
'); + return; + } + data = data.data; + if (data.length === 0) { + setArtTip('暂时没有文章
'); + return; + } + for (var i = 0; i < data.length; i++) { + qSlt(".article-content").innerHTML += '' + data[i].title + '' + data[i].timestamp + '
'; + } +}); +feed.addEventListener("error", function () { + qSlt(".article-container").classList.add("loaded"); + setArtTip('暂时无法连接到博客
'); +}); +feed.send(); +var sBg = bgArr[Math.floor(Math.random() * bgArr.length)]; +qSlt(".background-layer").style.backgroundImage = "url(" + sBg.thumb + ")"; +var bgLoader = new Image(); +bgLoader.src = sBg.url; +var bgTimeout = -1; + +function bgHandler() { + bgTimeout === -1 ? 0 : clearTimeout(bgTimeout); + qSlt(".background-layer").style.backgroundImage = "url(" + sBg.url + ")"; + qSlt(".background-layer").classList.remove("loading"); +} + +bgLoader.complete ? bgHandler() : (function () { + bgLoader.addEventListener("load", bgHandler); + bgTimeout = setTimeout(function () { + qSlt(".background-layer").classList.add("loading"); + }, 1000); +})(); +var doki = new Typinyin(); +randomSet(senArr); +doki.setOptions({ + sentences: senArr, + startDelay: 1000, + typeSpeed: 100, + pause: 3000, + backSpeed: 60, + cursorChar: "|", + loop: true, +}); +window.addEventListener("DOMContentLoaded", function () { + qSlt(".circle-line").addEventListener("animationiteration", function () { + doki.attach(".dokidoki-text"); + qSlt(".self-avatar").classList.add("finished"); + qSlt(".content-layer").classList.add("finished"); + setTimeout(function () { + document.body.classList.remove("locked"); + qSlt(".content-layer").classList.remove("finished"); + qSlt(".self-avatar").classList.add("no-delay"); + doki.init(); + }, 1500); + qSltAll(".switcher-btn").forEach(function (v) { + var id = v.id.substr(-1); + v.addEventListener("click", function () { + qSlt(".self-wrapper").style.transform = "translateX(-" + 33.3 * (parseInt(id) - 1) + "%)"; + qSlt(".btn-select-indicator").style.left = "" + 33.3 * (parseInt(id) - 1) + "%"; + qSlt(".selected").classList.remove("selected"); + v.classList.add("selected"); + }); + }); + }, {once: true}); +}); +console.log("\n %c Present %c By Zapic \n\n", "color: #fff; background: #fb7299; padding:5px 0;", "background: #efefef; padding:5px 0;"); \ No newline at end of file