一点点优化:

网址:http://blog.xinac.cn/ 内容正在建设中。
1、全部日期样式改为:yyyy-MM-dd EE
2、首页和文章详情页增加了评论量、浏览量、标签,页脚显示靠左
3、主题设置增加 关注我和文章代码主题
4、友链按排序显示
5、摘要如果有代码时,样式会有问题,增加 word-break: break-word;
v1.2.0
jinqilin721 2020-03-11 17:58:51 +08:00
parent 3099320526
commit b9fd5995d0
19 changed files with 582 additions and 109 deletions

View File

@ -20,7 +20,7 @@
</#if>
<div class="media-content">
<div class="content">
<time class="has-text-grey is-size-7 is-block is-uppercase" datetime="${post.createTime!}">${post.createTime?string["EEE MMM d"]}</time>
<time class="has-text-grey is-size-7 is-block is-uppercase" datetime="${post.createTime!}">${post.createTime?string["yyyy-MM-dd EE"]}</time>
<a href="${context!}/archives/${post.url!}" class="title has-link-black-ter is-size-6 has-text-weight-normal">${post.title!}</a>
</div>
</div>

View File

@ -22,7 +22,7 @@
<div class="level article-meta is-size-7 is-uppercase is-mobile is-overflow-x-auto">
<div class="level-left">
<time class="level-item has-text-grey"
datetime="${post.createTime!}">${post.createTime?string["EEE MMM d"]}</time>
datetime="${post.createTime!}">${post.createTime?string["yyyy-MM-dd EE"]}</time>
<#if index>
<#if post.categories?? && post.categories?size gt 0>
<div class="level-item">
@ -43,6 +43,12 @@
</#if>
</#if>
</div>
<div class="level-right">
<div class="level-item">
<span class="level-item has-text-grey">评论(${post.commentCount!'0'})</span>
<span class="level-item has-text-grey">浏览(${post.visits!'0'})</span>
</div>
</div>
</div>
<#if is_post??>
<h1 class="title is-size-3 is-size-4-mobile has-text-weight-normal">
@ -62,7 +68,6 @@
</h1>
</#if>
<div id="<#if is_post??>post-article<#else>is-hidden-touch</#if>" class="content <#if is_post?? || is_sheet??>post-article<#else>is-hidden-touch</#if>">
<#if index && post.summary?? && post.summary!=''>
${post.summary!}
@ -70,65 +75,79 @@
${post.formatContent!}
</#if>
</div>
<#if !index && tags?? && (tags?size gt 0)>
<div class="level is-size-7 is-uppercase">
<#if !index>
<div class="level is-size-7 is-uppercase is-mobile">
<div class="level-start">
<#if tags?? && (tags?size gt 0)>
<div class="level-item">
<span class="is-size-6 has-text-grey has-mr-7">#</span>
<#list tags as tag>
<a class="has-link-grey -link" style="margin-left: 10px;" href="${context!}/tags/${tag.slugName!}">${tag.name!}</a>&nbsp;
</#list>
</div>
</#if>
</div>
<div class="level-end">
<div class="level-item">
<span class="is-size-6 has-text-grey has-mr-7">#</span>
<#list tags as tag>
<a class="has-link-grey -link"
href="${context!}/tags/${tag.slugName!}">${tag.name!}</a>&nbsp;
</#list>
<span class="has-text-grey">最后编辑时间:${post.editTime!?string('yyyy-MM-dd HH:mm:ss')}</span>
</div>
</div>
</div>
</#if>
<#if index && post.summary?? && post.summary!=''>
<#if index>
<div class="level is-mobile">
<div class="level-start">
<div class="level-item">
<a class="button is-size-7 is-light" href="${context!}/archives/${post.url!}#more">阅读更多</a>
</div>
<#if post.tags?? && (post.tags?size gt 0)>
<div class="level-item">
<span class="is-size-6 has-text-grey has-mr-7">#</span>
<#list post.tags as tag>
<a class="has-link-grey -link" style="margin-left: 10px;" href="${context!}/tags/${tag.slugName!}">${tag.name!}</a>&nbsp;
</#list>
</div>
</#if>
</div>
<#if post.summary?? && post.summary!=''>
<div class="level-end">
<div class="level-item">
<a class="button is-size-7 is-light" href="${context!}/archives/${post.url!}#more">阅读更多</a>
</div>
</div>
</#if>
</div>
</#if>
</div>
</div>
<#if !index>
<div class="card" style="font-size: 20px;
line-height: 1.5em;
padding: 5px;
color: black;
background-color: rgba(255, 255, 255, 0.7);
border-left: 3px solid skyblue;">
<div class="card-content">
<p style="font-size: 15px;">本文由 <a href="${context!}">${user.nickname!}</a> 创作,如果您觉得本文不错,请随意赞赏<br>采用 <a
href="https://creativecommons.org/licenses/by/4.0/" target="_blank"
rel="external nofollow">知识共享署名4.0</a> 国际许可协议进行许可<br>本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名<br>原文链接:<a
href="${context!}/archives/${post.url!}">${context!}
/archives/${post.url!}</a><br>最后更新于:${post.editTime?string('yyyy-MM-dd HH:mm:ss')}
</p>
</div>
</div>
</#if>
<#if !index>
<#if (settings.donate_alipay?? && settings.donate_alipay!='') || (settings.donate_wechat?? && settings.donate_wechat!='')>
<div class="card">
<div class="card" style="font-size: 20px; line-height: 1.5em; padding: 5px; color: black; background-color: rgba(255, 255, 255, 0.7); border-left: 3px solid skyblue;">
<div class="card-content">
<h3 class="menu-label has-text-centered">喜欢这篇文章?打赏一下作者吧</h3>
<div class="buttons is-centered">
<#if settings.donate_alipay?? && settings.donate_alipay!=''>
<#include "../donate/alipay.ftl">
</#if>
<#if settings.donate_wechat?? && settings.donate_wechat!=''>
<#include "../donate/wechat.ftl">
</#if>
</div>
<p style="font-size: 15px;">
本文由 <a target="_blank" href="${context!}">${user.nickname!}</a> 创作,如果您觉得本文不错,请随意赞赏<br>
采用 <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/" rel="external nofollow">知识共享署名4.0</a> 国际许可协议进行许可<br>
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名<br>
原文链接:<a target="_blank" href="${context!}/archives/${post.url!}">${context!}/archives/${post.url!}</a><br>
最后更新:${post.editTime?string('yyyy-MM-dd HH:mm:ss')}
</p>
</div>
</div>
</#if>
</#if>
<#if !index>
<#if (settings.donate_alipay?? && settings.donate_alipay!='') || (settings.donate_wechat?? && settings.donate_wechat!='')>
<div class="card">
<div class="card-content">
<h3 class="menu-label has-text-centered">喜欢这篇文章?打赏一下作者吧</h3>
<div class="buttons is-centered">
<#if settings.donate_alipay?? && settings.donate_alipay!=''>
<#include "../donate/alipay.ftl">
</#if>
<#if settings.donate_wechat?? && settings.donate_wechat!=''>
<#include "../donate/wechat.ftl">
</#if>
</div>
</div>
</div>
</#if>
</#if>
<#if !index && nextPost?? && prePost??>
<div class="card card-transparent">

View File

@ -2,17 +2,16 @@
<div class="container">
<div class="level">
<div class="level-start has-text-centered-mobile">
&nbsp;&nbsp;&nbsp;<@global.footer />
<#if settings.busuanzi!true>
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<br>
<span id="busuanzi_container_site_pv" style='display:none'>&nbsp;&nbsp;&nbsp; 总访问量 <span
id="busuanzi_value_site_pv"></span> 次 </span>
<span id="busuanzi_container_site_uv" style='display:none'>| 总访客数 <span
id="busuanzi_value_site_uv"></span> 人 </span>
<p style="text-align: left; line-height: 20px; margin: 0">
<script async src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
<br>
<span id="busuanzi_container_site_pv" style='display:none'>总访问量 <span id="busuanzi_value_site_pv"></span> 次 </span>
<span id="busuanzi_container_site_uv" style='display:none'>| 总访客数 <span id="busuanzi_value_site_uv"></span> 人 </span>
</p>
</#if>
<#if settings.bokejishi!true>
<p style="text-align: center; line-height: 20px;margin: 0">
<p style="text-align: left; line-height: 20px;margin: 0">
我的博客已经运行&nbsp;&nbsp;<span id="clock"></span>&nbsp;&nbsp;啦!<br>
</p>
<script type="text/javascript">
@ -46,16 +45,19 @@
</script>
</#if>
<#if settings.social_beian?? && settings.social_beian!=''>
<p style="text-align: center; line-height: 20px;margin: 0">
<a href="http://beian.miit.gov.cn/"
style="color: black;font-style: inherit;font-weight: inherit;">${settings.social_beian!}</a>
<p style="text-align: left; line-height: 20px;margin: 0">
<a href="http://beian.miit.gov.cn/" style="color: black;font-style: inherit;font-weight: inherit;">
${settings.social_beian!}
</a>
</p>
</#if>
<#if settings.social_free?? && settings.social_free!=''>
${settings.social_free!}
<p style="text-align: left; line-height: 20px; margin: 0">
&copy; ${.now?string('yyyy')} ${user.nickname!}&nbsp;${settings.social_free!}
</p>
</#if>
<#if settings.caidai!true>
<script src="https://www.lwjppz.cn/upload/2020/2/caidai-5e8e10ce0efc4886838a9ea8c5e1153a.js"></script>
<script src="${static!}/source/lib/caidai.js?date=${.now?string('yyyyMM')}"></script>
</#if>
<#if settings.xiantiao!true>
<script type="text/javascript"
@ -64,9 +66,10 @@
</script>
</#if>
<#if settings.dianji!true>
<script src="https://www.lwjppz.cn/upload/2020/2/dianji-1a07321c18b640deafcb13f4cb635307.js"></script>
<script src="${static!}/source/lib/dianji.js?date=${.now?string('yyyyMM')}"></script>
</#if>
</p>
<@global.footer />
</div>
<div class="level-end">
<div class="field has-addons is-flex-center-mobile has-mt-5-mobile is-flex-wrap is-flex-middle">

View File

@ -21,7 +21,7 @@
</a>
</div>
<div class="blog-slider__content">
<span class="blog-slider__code">${post.createTime?string["EEE MMM d"]}</span>
<span class="blog-slider__code">${post.createTime?string["yyyy-MM-dd EE"]}</span>
<div class="blog-slider__title "><a class="title is-5" href="${context!}/archives/${post.url!}">${post.title!}</a></div>
<div class="blog-slider__text" content="">${post.summary!}</div>
<a href="${context!}/archives/${post.url!}" class="blog-slider__button">阅读更多</a>

View File

@ -25,7 +25,7 @@
<link rel="canonical" href="${canonical!}"/>
<link rel="alternative" href="${context!}/atom.xml" title="${options.blog_title!}" type="application/atom+xml">
<link rel="alternative" href="${context!}/atom" title="${options.blog_title!}" type="application/atom+xml">
<@global.head />
@ -66,11 +66,9 @@
<#if is_post?? || is_sheet?? || is_journal??>
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/lightgallery@1.6.8/dist/css/lightgallery.min.css">
<link rel="stylesheet"
href="//cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/justifiedGallery@3.7.0/dist/css/justifiedGallery.min.css">
</#if>
<link rel="stylesheet"
href="//cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/outdatedbrowser@1.1.5/outdatedbrowser/outdatedbrowser.min.css">
<script src="//cdn.jsdelivr.net/npm/pace-js@1.0.2/pace.min.js"></script>
<link rel="stylesheet" href="${static!}/source/css/style.css">
@ -78,8 +76,7 @@
<link rel="stylesheet" href="${static!}/source/css/back-to-top.css">
<#include "./plugin/style.theme.ftl">
<#if post?? || journals??>
<link rel="stylesheet" type="text/css"
href="${static!}/source/lib/prism/css/prism-Tomorrow Night.css"/>
<link rel="stylesheet" type="text/css" href="${static!}/source/lib/prism/css/prism-${settings.code_pretty!'Default'}.css"/>
<script type="text/javascript" src="${static!}/source/lib/prism/js/prism.js"></script>
</#if>
<#if is_index??>
@ -117,7 +114,7 @@
style="margin-left: 10px">
<div class="columns">
<div class="column is-12-tablet is-12-desktop is-12-widescreen has-order-2 column-main">
<#-- 判断是否已经有置顶文章-->
<#--判断是否已经有置顶文章-->
<#list posts.content as post>
<#if post.topPriority == 1>
<#assign isTop = 'yes'>
@ -126,7 +123,7 @@
</#list>
<#if isTop??>
<div class="level">
<#-- <#include "./common/widget_pin.ftl">-->
<#--<#include "./common/widget_pin.ftl">-->
<@module 'slider' />
</div>
</#if>

View File

@ -17,7 +17,7 @@
</#if>
<div class="media-content">
<div class="content">
<div><time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["EEE MMM d"]}</time></div>
<div><time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["yyyy-MM-dd EE"]}</time></div>
<a href="${context!}/archives/${post.url!}" class="title has-link-black-ter is-size-6 has-text-weight-normal">${post.title!}</a>
</div>
</div>

View File

@ -7,7 +7,7 @@
链接
</h3>
<ul class="menu-list">
<#list links as link>
<#list links?sort_by("priority") as link>
<li>
<a class="level is-mobile" href="${link.url!}" target="_blank">
<span class="level-left">

View File

@ -3,7 +3,7 @@
<nav class="level">
<div class="level-item has-text-centered" style="flex-shrink: 1">
<div class="level">
<figure class="image is-64x64 has-mb-6 level-left" style="margin: 0 auto">
<figure class="image is-96x96 has-mb-6 level-left" style="margin: 0 auto">
<img class="is-rounded"
src="${user.avatar!}" alt="${user.nickname!}" style="padding: 2px;
box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1);">
@ -61,6 +61,11 @@ box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1);">
</div>
</div>
</nav>
<#if settings.profile_follow_url?? && settings.profile_follow_url!=''>
<div class="level">
<a class="level-item button is-link is-rounded" style="background-color: #3273dc !important; border-color: transparent !important; color: #fff !important;" href="${settings.profile_follow_url!'${context!}'}" target="_blank">关注我</a>
</div>
</#if>
<#-- <div class="level">-->
<#-- <a class="level-item button is-link is-rounded" href="${settings.profile_follow_url!'${context!}'}"-->
<#-- target="_blank">关注我</a>-->
@ -108,7 +113,7 @@ box-shadow: 0 1px 2px 0 rgba(0,0,0,0.1);">
<i class="fab fa-telegram"></i>
</a>
</#if>
<a class="level-item button is-marginless" target="_blank" title="RSS" href="${context!}/atom.xml">
<a class="level-item button is-marginless" target="_blank" title="RSS" href="${context!}/atom">
<i class="fas fa-rss"></i>
</a>
</div>

View File

@ -16,7 +16,7 @@
<div class="media-content">
<div class="content">
<div style="padding-top: 10px;">
<time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["EEE MMM d"]}</time>
<time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["yyyy-MM-dd EE"]}</time>
</div>
<a href="${context!}/archives/${post.url!}" class="title has-link-black-ter is-size-6 has-text-weight-normal">${post.title!}</a>
</div>

View File

@ -17,7 +17,7 @@
</#if>
<div class="media-content">
<div class="content">
<div><time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["EEE MMM d"]}</time></div>
<div><time class="has-text-grey is-size-7 is-uppercase" datetime="${post.createTime!}">${post.createTime?string["yyyy-MM-dd EE"]}</time></div>
<a href="${context!}/archives/${post.url!}" class="title has-link-black-ter is-size-6 has-text-weight-normal">${post.title!}</a>
</div>
</div>

View File

@ -32,7 +32,7 @@
return result;
},
createPostDirectory = function (article, directory, isDirNum) {
console.log("aaa",article,directory,isDirNum);
// console.log("aaa",article,directory,isDirNum);
var contentArr = [],
titleId = [],
levelArr, root, level,
@ -135,7 +135,7 @@
var offsetLength = dir.offset().top
$(document).scroll(function() {
var distance = offsetLength - $(window).scrollTop();
console.log(distance)
// console.log(distance)
// console.log(allpostdiv)
if (distance <= 0) {
if (!dir.hasClass('directory-fixed')) {
@ -176,7 +176,7 @@
var offsetLength = dir.offset().top
$(document).scroll(function () {
var distance = offsetLength - $(window).scrollTop();
console.log(distance)
// console.log(distance)
// console.log(allpostdiv)
if (distance <= 0) {
if (!dir.hasClass('directory-fixed')) {

View File

@ -2,12 +2,12 @@
<#include "layout/common/article.ftl">
<#include "layout/comment/comment.ftl">
<@layout title="链接 - ${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" canonical="${context!}/links">
<#include "layout/widget/links.ftl">
<div class="card widget">
<div class="card-content">
<h1 class="menu-label" style="font-size: 20px; text-align:center;">友链申请</h1>
<div style="margin-left: 10px">
<div class="card widget">
<div class="card-content">
<h1 class="menu-label" style="font-size: 20px; text-align:center;">友链申请</h1>
<div style="margin-left: 10px">
<h2 style="font-size: 15px; font-weight: bold"># 友链须知</h2>
<div style="border-left: 3px solid skyblue; margin-left: 20px">
<p style="margin-left: 20px; font-weight: bold">1. 请确认您的网站可正常访问</p>
@ -16,37 +16,37 @@
<p style="margin-left: 20px; font-weight: bold">4. 没有广告</p>
<p style="margin-left: 20px; font-weight: bold">5. 添加本站链接</p>
</div>
<h2 style="font-size: 15px; font-weight: bold"># 本站信息</h2>
<div style="border-left: 3px solid skyblue; margin-left: 20px">
<p style="margin-left: 20px; font-weight: bold">name罗罗</p>
<p style="margin-left: 20px; font-weight: bold">avatar<a href="https://www.lwjppz.cn/avatar">avatar</a></p>
<p style="margin-left: 20px; font-weight: bold">descption一个非常不爱敲代码的大学生</p>
<p style="margin-left: 20px; font-weight: bold">href<a href="https://www.lwjppz.cn/">https://www.lwjppz.cn</a></p>
</div>
<p style="margin-left: 10px; font-weight: bold">本人会不定期清理无法访问的链接,请确保自己的链接长期有效
</p>
<p style="margin-left: 10px; font-weight: bold">有需要互换友链的童鞋也可在下方评论区留言。</p>
<h2 style="font-size: 15px; font-weight: bold"># 本站信息</h2>
<div style="border-left: 3px solid skyblue; margin-left: 20px">
<p style="margin-left: 20px; font-weight: bold">名称:${user.nickname!}</p>
<p style="margin-left: 20px; font-weight: bold">链接:<a target="_blank" href="${context!}">${context!}</a></p>
<p style="margin-left: 20px; font-weight: bold">头像:<a target="_blank" href="${context!}/avatar">${context!}/avatar</a></p>
<p style="margin-left: 20px; font-weight: bold">描述:${user.description!}</p>
</div>
<p style="margin-left: 10px; font-weight: bold">本人会不定期清理无法访问的链接,请确保自己的链接长期有效
</p>
<p style="margin-left: 10px; font-weight: bold">有需要互换友链的童鞋也可在下方评论区留言。</p>
</div>
</div>
<div class="card" style="margin-top: 2rem">
<div class="card-content">
<p class="title is-5">
评论
</p>
<div class="content">
<div class="post-comment-wrap">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/halo-comment-normal@1.1.1/dist/halo-comment.min.js"></script>
<script>
</div>
<div class="card" style="margin-top: 2rem">
<div class="card-content">
<p class="title is-5">
评论
</p>
<div class="content">
<div class="post-comment-wrap">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/halo-comment-normal@1.1.1/dist/halo-comment.min.js"></script>
<script>
// var configs = {
// autoLoad: true,
// showUserAgent: true
// }
</script>
<halo-comment id="59" type="sheet">
</halo-comment></div>
</div>
</div>
</div>
</script>
<halo-comment id="59" type="sheet"></halo-comment>
</div>
</div>
</div>
</div>
</@layout>

View File

@ -21,7 +21,7 @@
<link rel="canonical" href="${canonical!}"/>
<link rel="alternative" href="${context!}/atom.xml" title="${options.blog_title!}" type="application/atom+xml">
<link rel="alternative" href="${context!}/atom" title="${options.blog_title!}" type="application/atom+xml">
<@global.head />

View File

@ -12,6 +12,11 @@ sidebar:
label: 开启
- value: false
label: 关闭
profile_follow_url:
name: profile_follow_url
label: 【关注我】按钮地址
type: text
placeholder: '默认为博客地址'
sidebar_profile:
name: sidebar_profile
label: 侧边栏个人资料
@ -160,6 +165,36 @@ post:
label: 开启
- value: false
label: 关闭
code_pretty:
name: code_pretty
label: 文章代码高亮主题
type: select
default: Default
options:
- value: Default
label: Default
- value: Coy
label: Coy
- value: Dark
label: Dark
- value: Okaidia
label: Okaidia
- value: Solarized Light
label: Solarized Light
- value: Tomorrow Night
label: Tomorrow Night
- value: Twilight
label: Twilight
# code_pretty:
# name: code_pretty
# label: 文章代码高亮主题
# type: select
# default: light
# options:
# - value: Dark
# label: dark
# - value: light
# label: light
social:
label: 博客信息
items:

View File

@ -238,6 +238,7 @@ img.thumbnail {
}
.article .content {
font-size: 1.1rem;
word-break: break-word;
}
.article .content blockquote.pullquote {
float: right;
@ -247,6 +248,7 @@ img.thumbnail {
}
.article .content a {
word-wrap: break-word;
word-break: break-word;
}
.article .content p {
line-height: 1.9rem;
@ -566,6 +568,7 @@ video {
}
.post-article {
word-wrap: break-word;
word-break: break-word;
line-height: 1.8;
letter-spacing: 0.013rem;
}
@ -630,6 +633,10 @@ p {
margin-bottom: 0
}
.timeline .media {
margin-bottom: 20px !important;
}
.media+.media {
padding-top: 0;
}

View File

@ -182,6 +182,7 @@ img.thumbnail
padding-top: 1rem
border-left: 1px solid hsl(0, 0%, 86%)
.media
margin-bottom: 20px !important
position: relative
&:before,
&:last-child:after

324
source/lib/caidai.js Normal file
View File

@ -0,0 +1,324 @@
(function (name, factory) {
if (typeof window === "object") {
window[name] = factory()
}
})("Ribbons", function () {
var _w = window,
_b = document.body,
_d = document.documentElement;
var random = function () {
if (arguments.length === 1) {
if (Array.isArray(arguments[0])) {
var index = Math.round(random(0, arguments[0].length - 1));
return arguments[0][index]
}
return random(0, arguments[0])
} else if (arguments.length === 2) {
return Math.random() * (arguments[1] - arguments[0]) + arguments[0]
}
return 0
};
var screenInfo = function (e) {
var width = Math.max(0, _w.innerWidth || _d.clientWidth || _b.clientWidth || 0),
height = Math.max(0, _w.innerHeight || _d.clientHeight || _b.clientHeight || 0),
scrollx = Math.max(0, _w.pageXOffset || _d.scrollLeft || _b.scrollLeft || 0) - (_d.clientLeft || 0),
scrolly = Math.max(0, _w.pageYOffset || _d.scrollTop || _b.scrollTop || 0) - (_d.clientTop || 0);
return {
width: width,
height: height,
ratio: width / height,
centerx: width / 2,
centery: height / 2,
scrollx: scrollx,
scrolly: scrolly
}
};
var mouseInfo = function (e) {
var screen = screenInfo(e),
mousex = e ? Math.max(0, e.pageX || e.clientX || 0) : 0,
mousey = e ? Math.max(0, e.pageY || e.clientY || 0) : 0;
return {
mousex: mousex,
mousey: mousey,
centerx: mousex - screen.width / 2,
centery: mousey - screen.height / 2
}
};
var Point = function (x, y) {
this.x = 0;
this.y = 0;
this.set(x, y)
};
Point.prototype = {
constructor: Point,
set: function (x, y) {
this.x = x || 0;
this.y = y || 0
},
copy: function (point) {
this.x = point.x || 0;
this.y = point.y || 0;
return this
},
multiply: function (x, y) {
this.x *= x || 1;
this.y *= y || 1;
return this
},
divide: function (x, y) {
this.x /= x || 1;
this.y /= y || 1;
return this
},
add: function (x, y) {
this.x += x || 0;
this.y += y || 0;
return this
},
subtract: function (x, y) {
this.x -= x || 0;
this.y -= y || 0;
return this
},
clampX: function (min, max) {
this.x = Math.max(min, Math.min(this.x, max));
return this
},
clampY: function (min, max) {
this.y = Math.max(min, Math.min(this.y, max));
return this
},
flipX: function () {
this.x *= -1;
return this
},
flipY: function () {
this.y *= -1;
return this
}
};
var Factory = function (options) {
this._canvas = null;
this._context = null;
this._sto = null;
this._width = 0;
this._height = 0;
this._scroll = 0;
this._ribbons = [];
this._options = {
colorSaturation: "80%",
colorBrightness: "60%",
colorAlpha: 0.65,
colorCycleSpeed: 6,
verticalPosition: "center",
horizontalSpeed: 150,
ribbonCount: 5,
strokeSize: 5,
parallaxAmount: -0.5,
animateSections: true
};
this._onDraw = this._onDraw.bind(this);
this._onResize = this._onResize.bind(this);
this._onScroll = this._onScroll.bind(this);
this.setOptions(options);
this.init()
};
Factory.prototype = {
constructor: Factory,
setOptions: function (options) {
if (typeof options === "object") {
for (var key in options) {
if (options.hasOwnProperty(key)) {
this._options[key] = options[key]
}
}
}
},
init: function () {
try {
this._canvas = document.createElement("canvas");
this._canvas.style["display"] = "block";
this._canvas.style["position"] = "fixed";
this._canvas.style["margin"] = "0";
this._canvas.style["padding"] = "0";
this._canvas.style["border"] = "0";
this._canvas.style["outline"] = "0";
this._canvas.style["left"] = "0";
this._canvas.style["top"] = "0";
this._canvas.style["width"] = "100%";
this._canvas.style["height"] = "100%";
this._canvas.style["z-index"] = "-1";
this._onResize();
this._context = this._canvas.getContext("2d");
this._context.clearRect(0, 0, this._width, this._height);
this._context.globalAlpha = this._options.colorAlpha;
window.addEventListener("resize", this._onResize);
window.addEventListener("scroll", this._onScroll);
document.body.appendChild(this._canvas)
} catch (e) {
console.warn("Canvas Context Error: " + e.toString());
return
}
this._onDraw()
},
addRibbon: function () {
var dir = Math.round(random(1, 9)) > 5 ? "right" : "left",
stop = 1000,
hide = 200,
min = 0 - hide,
max = this._width + hide,
movex = 0,
movey = 0,
startx = dir === "right" ? min : max,
starty = Math.round(random(0, this._height));
if (/^(top|min)$/i.test(this._options.verticalPosition)) {
starty = 0 + hide
} else if (/^(middle|center)$/i.test(this._options.verticalPosition)) {
starty = this._height / 2
} else if (/^(bottom|max)$/i.test(this._options.verticalPosition)) {
starty = this._height - hide
}
var ribbon = [],
point1 = new Point(startx, starty),
point2 = new Point(startx, starty),
point3 = null,
color = Math.round(random(0, 360)),
delay = 0;
while (true) {
if (stop <= 0) break;
stop--;
movex = Math.round((Math.random() * 1 - 0.2) * this._options.horizontalSpeed);
movey = Math.round((Math.random() * 1 - 0.5) * (this._height * 0.25));
point3 = new Point();
point3.copy(point2);
if (dir === "right") {
point3.add(movex, movey);
if (point2.x >= max) break
} else if (dir === "left") {
point3.subtract(movex, movey);
if (point2.x <= min) break
}
ribbon.push({
point1: new Point(point1.x, point1.y),
point2: new Point(point2.x, point2.y),
point3: point3,
color: color,
delay: delay,
dir: dir,
alpha: 0,
phase: 0
});
point1.copy(point2);
point2.copy(point3);
delay += 4;
color += this._options.colorCycleSpeed
}
this._ribbons.push(ribbon)
},
_drawRibbonSection: function (section) {
if (section) {
if (section.phase >= 1 && section.alpha <= 0) {
return true
}
if (section.delay <= 0) {
section.phase += 0.02;
section.alpha = Math.sin(section.phase) * 1;
section.alpha = section.alpha <= 0 ? 0 : section.alpha;
section.alpha = section.alpha >= 1 ? 1 : section.alpha;
if (this._options.animateSections) {
var mod = Math.sin(1 + section.phase * Math.PI / 2) * 0.1;
if (section.dir === "right") {
section.point1.add(mod, 0);
section.point2.add(mod, 0);
section.point3.add(mod, 0)
} else {
section.point1.subtract(mod, 0);
section.point2.subtract(mod, 0);
section.point3.subtract(mod, 0)
}
section.point1.add(0, mod);
section.point2.add(0, mod);
section.point3.add(0, mod)
}
} else {
section.delay -= 0.5
}
var s = this._options.colorSaturation,
l = this._options.colorBrightness,
c = "hsla(" + section.color + ", " + s + ", " + l + ", " + section.alpha + " )";
this._context.save();
if (this._options.parallaxAmount !== 0) {
this._context.translate(0, this._scroll * this._options.parallaxAmount)
}
this._context.beginPath();
this._context.moveTo(section.point1.x, section.point1.y);
this._context.lineTo(section.point2.x, section.point2.y);
this._context.lineTo(section.point3.x, section.point3.y);
this._context.fillStyle = c;
this._context.fill();
if (this._options.strokeSize > 0) {
this._context.lineWidth = this._options.strokeSize;
this._context.strokeStyle = c;
this._context.lineCap = "round";
this._context.stroke()
}
this._context.restore()
}
return false
},
_onDraw: function () {
for (var i = 0, t = this._ribbons.length; i < t; ++i) {
if (!this._ribbons[i]) {
this._ribbons.splice(i, 1)
}
}
this._context.clearRect(0, 0, this._width, this._height);
for (var a = 0; a < this._ribbons.length; ++a) {
var ribbon = this._ribbons[a],
numSections = ribbon.length,
numDone = 0;
for (var b = 0; b < numSections; ++b) {
if (this._drawRibbonSection(ribbon[b])) {
numDone++
}
}
if (numDone >= numSections) {
this._ribbons[a] = null
}
}
if (this._ribbons.length < this._options.ribbonCount) {
this.addRibbon()
}
requestAnimationFrame(this._onDraw)
},
_onResize: function (e) {
var screen = screenInfo(e);
this._width = screen.width;
this._height = screen.height;
if (this._canvas) {
this._canvas.width = this._width;
this._canvas.height = this._height;
if (this._context) {
this._context.globalAlpha = this._options.colorAlpha
}
}
},
_onScroll: function (e) {
var screen = screenInfo(e);
this._scroll = screen.scrolly
}
};
return Factory
});
new Ribbons({
colorSaturation: "60%",
colorBrightness: "50%",
colorAlpha: 0.5,
colorCycleSpeed: 5,
verticalPosition: "random",
horizontalSpeed: 200,
ribbonCount: 3,
strokeSize: 0,
parallaxAmount: -0.2,
animateSections: true
});

80
source/lib/dianji.js Normal file
View File

@ -0,0 +1,80 @@
(function(window,document,undefined){
var hearts = [];
window.requestAnimationFrame = (function(){
return window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.oRequestAnimationFrame ||
window.msRequestAnimationFrame ||
function (callback){
setTimeout(callback,1000/60);
}
})();
init();
function init(){
css(".heart{width: 10px;height: 10px;position: fixed;background: #f00;transform: rotate(45deg);-webkit-transform: rotate(45deg);-moz-transform: rotate(45deg);}.heart:after,.heart:before{content: '';width: inherit;height: inherit;background: inherit;border-radius: 50%;-webkit-border-radius: 50%;-moz-border-radius: 50%;position: absolute;}.heart:after{top: -5px;}.heart:before{left: -5px;}");
attachEvent();
gameloop();
}
function gameloop(){
for(var i=0;i<hearts.length;i++){
if(hearts[i].alpha <=0){
document.body.removeChild(hearts[i].el);
hearts.splice(i,1);
continue;
}
hearts[i].y--;
hearts[i].scale += 0.004;
hearts[i].alpha -= 0.013;
hearts[i].el.style.cssText = "left:"+hearts[i].x+"px;top:"+hearts[i].y+"px;opacity:"+hearts[i].alpha+";transform:scale("+hearts[i].scale+","+hearts[i].scale+") rotate(45deg);background:"+hearts[i].color;
}
requestAnimationFrame(gameloop);
}
function attachEvent(){
var old = typeof window.onclick==="function" && window.onclick;
window.onclick = function(event){
old && old();
createHeart(event);
}
}
function createHeart(event){
var d = document.createElement("div");
d.className = "heart";
hearts.push({
el : d,
x : event.clientX - 5,
y : event.clientY - 5,
scale : 1,
alpha : 1,
color : randomColor()
});
document.body.appendChild(d);
}
function css(css){
var style = document.createElement("style");
style.type="text/css";
try{
style.appendChild(document.createTextNode(css));
}
catch(ex){
style.styleSheet.cssText = css;
}
document.getElementsByTagName('head')[0].appendChild(style);
}
function randomColor(){
return "rgb("+(~~(Math.random()*255))+","+(~~(Math.random()*255))+","+(~~(Math.random()*255))+")";
}
})(window,document);

2
source/lib/toc/toc.min.js vendored Normal file
View File

@ -0,0 +1,2 @@
!function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:r})},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=0)}([function(t,e,n){"use strict";(function(t){var n,r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=function(){function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.wrapperId?this.container=document.getElementById(e.wrapperId):this.container=document.body,e.insertId?this.insertDom=document.getElementById(e.insertId):this.container!=document.body?this.insertDom=this.container:this.insertDom=this.container.firstElementChild,this.showSerial=e.showSerial||!1,this.childH=[]}return i(t,[{key:"getAllH",value:function(){for(var t=this.container.firstElementChild;t;)t.nodeName.match(/H[1-7]/)&&(t.order=parseInt(t.nodeName[1]),this.childH.push(t)),t=t.nextElementSibling}},{key:"createItemChain",value:function(t,e){!function t(e,n){if(!e||!e[n])return;var r=e[n];r.childH=[];for(var i=n+1;i<e.length&&e[i].order>r.order;i++){var o=e.splice(i,1);r.childH=r.childH.concat(o),i--}r.childH.length&&t(r.childH,0);for(var c=n+1;c<e.length;c++)e[c].childH||t(e,c)}(t,e)}},{key:"createToc",value:function(){var t=this;if(this.getAllH(),this.createItemChain(this.childH,0),this.childH.length){var e=document.createElement("div");e.setAttribute("class","toc_wrap"),e.setAttribute("id","toc_wrap"),e.innerHTML='<div class="toc_root" id="toc"><a class="hide_toc_btn">[hide]</a></div><a class="show_toc_btn">[显示目录]</a>',this.insertDom.parentNode.insertBefore(e,this.insertDom),e.getElementsByClassName("hide_toc_btn")[0].addEventListener("click",function(){e.className=e.className+" hide"}),e.getElementsByClassName("show_toc_btn")[0].addEventListener("click",function(){e.className="toc_wrap"}),function e(n,r,i,o){var c=1;for(var l=0;l<r.length;l++){var a=document.createElement("div");a.setAttribute("class","toc_lvl toc_lvl_"+i);var s="";s=o?o+"."+c:c,t.showSerial&&s,a.innerHTML='<a href="#toc_'+s+'"">'+s+"&nbsp;"+r[l].innerHTML+"</a>",r[l].setAttribute("id","toc_"+s),n.appendChild(a),r[l].childH&&r[l].childH.length&&e(a,r[l].childH,i+1,s),c++}}(document.getElementById("toc"),this.childH,1,"")}}}]),t}();"object"===r(t)&&"object"===r(t.exports)&&(t.exports=o),"function"==typeof window.define?void 0===(n=function(){return o}.apply(e,[]))||(t.exports=n):window.Toc=o}).call(e,n(1)(t))},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}}]);
//# sourceMappingURL=toc.min.js.map