新主题改造

This commit is contained in:
结发受长生
2018-06-04 17:31:48 +08:00
parent 113825166a
commit f59ea1ea62
96 changed files with 5224 additions and 4 deletions
@@ -0,0 +1,9 @@
<%- partial('plugin/noscript') %>
<%- js('js/jquery.min.js') %>
<%- js('js/materialize.min.js') %>
<%- js('js/prettify.js') %>
<%- js('js/main.js') %>
<%- partial('plugin/analytics') %>
<%- partial('plugin/mathjax') %>
@@ -0,0 +1,79 @@
<%
var title = '';
var archiveHtml = null;
if (page.category) {
titleKey = 'categories';
archiveHtml = '<a class="breadcrumb" href="/' + page.base + '">' + page.category + '</a>';
}
if (page.tag) {
titleKey = 'tags';
archiveHtml = '<a class="breadcrumb" href="/' + page.base + '">' + page.tag + '</a>';
}
if (page.archive){
if (page.year) {
title = page.year + (page.month ? '/' + page.month : '');
} else {
titleKey = 'archives';
}
}
%>
<%- partial('pagenav', {nav_head: __('current_page') + __('page_name.' + titleKey), partial_path: null, archive_html: archiveHtml}) %>
<% if (pagination == 2){ %>
<% page.posts.each(function(item){ %>
<%- partial('simple_article', {item: item, index: true, showEntry: false, showTags: false}) %>
<% }); %>
<%- partial('pagination') %>
<% } else if (page.archive) { %>
<ul class="collapsible mt-0" data-collapsible="accordion">
<%
// 将各年份的文章汇总,数据结构为
// [{year: 2016, posts: [item1, item2]}, {year: 2015, posts: [item3, item4, item5]}]
var activeFlag = true;
var yearPosts = [];
page.posts.each(function(item) {
var y = item.date.year();
var yp;
if (yearPosts.length == 0 || yearPosts[yearPosts.length - 1].year != y) {
yp = {
year: y,
posts: [item]
};
yearPosts.push(yp);
} else {
yp = yearPosts[yearPosts.length - 1];
yp.posts.push(item);
}
});
%>
<% yearPosts.forEach(function(yearPost) { %>
<li>
<div class="collapsible-header <%= activeFlag ? 'active' : '' %><% activeFlag = false; %>">
<i class="fa fa-archive"></i><%= yearPost.year %>
</div>
<div class="collapsible-body">
<div class="collection">
<% yearPost.posts.forEach(function(item) { %>
<a href="<%- url_for(item.path) %>" class="collection-item <%= theme.color.archive_item %>-text text-darken-1">
<time datetime="<%= item.date.toDate().toISOString() %>"><%= item.date.format(config.date_format) %></time>
<span>&nbsp;&nbsp;&nbsp;</span>
<%- item.title %>
</a>
<% }); %>
</div>
</div>
</li>
<% }); %>
</ul>
<% } else { %>
<div class="collection mt-0">
<% page.posts.each(function(item) { %>
<a href="<%- url_for(item.path) %>" class="collection-item <%= theme.color.archive_item %>-text text-darken-1">
<time datetime="<%= item.date.toDate().toISOString() %>"><%= item.date.format(config.date_format) %></time>
<span>&nbsp;&nbsp;&nbsp;</span>
<%- item.title %>
</a>
<% }); %>
</div>
<% } %>
@@ -0,0 +1,15 @@
<article class="<%= item.layout %>">
<header>
<div class="icon"></div>
<time datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- url_for(item.path) %>"><%= item.date.format(config.date_format) %></a></time>
<% if (item.link){ %>
<% if (item.title){ %>
<h1 class="title link"><a href="<%- item.link %>" target="_blank"><%= item.title %></a></h1>
<% } else { %>
<h1 class="title link"><a href="<%- item.link %>" target="_blank"><%= item.link %></a></h1>
<% } %>
<% } else { %>
<h1 class="title"><a href="<%- url_for(item.path) %>"><%= item.title %></a></h1>
<% } %>
</header>
</article>
@@ -0,0 +1,26 @@
<%- partial('pagenav', {nav_head: __('current_page') + __('page_name.categories'), partial_path: 'post/category', archive_html: null}) %>
<article>
<div class="card">
<div class="card-content">
<% if (item.photos && item.photos.length) { %>
<%- partial('post/gallery') %>
<% } %>
<div class="article-title">
<%- partial('post/title') %>
</div>
<%- partial('post/time') %>
<%- partial('post/readtimes') %>
<%- partial('post/tag') %>
<%- partial('post/tablecontents') %>
<div class="entry <%= theme.color.link %>-link-context">
<%- item.content %>
<%- partial('post/prevnext') %>
</div>
</div>
</div>
</article>
<%- partial('plugin/comment') %>
@@ -0,0 +1,9 @@
<div class="center-align">
<div class="construction-container">
<div class="center-align">
<i class="fa fa-cog fa-spin" style="font-size: 8rem;"></i>
</div>
<h4><%= __('construction') %></h4>
<a href="/" class="waves-effect waves-light btn green"><%= __('go_back_home') %></a>
</div>
</div>
@@ -0,0 +1,9 @@
<div class="fixed-action-btn float-sitemap">
<a class="btn-floating btn-large <%= theme.color.fab %>">
<i class="fa fa-caret-square-o-up"></i>
</a>
<ul>
<li><a class="btn-return-top btn-floating waves-effect <%= theme.color.fab_2 %>" title="<%- __('returntop') %>"><i class="fa fa-arrow-circle-o-up"></i></a></li>
<li><a class="btn-floating waves-effect button-collapse <%= theme.color.fab_3 %>" data-activates="main-menu" title="<%- __('floatmenu') %>"><i class="fa fa-navicon"></i></a></li>
</ul>
</div>
@@ -0,0 +1,35 @@
<footer class="page-footer <%= theme.color.footer %> darken-1">
<% if (site.data.link) { %>
<div class="footer-container container">
<div class="row">
<% if (site.data.link.social) { %>
<div class="social-group col m4 s12">
<h5 class="white-text"><%= __('social') %></h5>
<% for (var type in site.data.link.social) { %>
<a class="social-link" href="<%= site.data.link.social[type] %>" target="_blank">
<i class="fa fa-2x fa-<%= type %>"></i>
</a>
<% } %>
<%- partial('plugin/page_stat') %>
</div>
<% } %>
<% if (site.data.link && site.data.link.extern) { %>
<div class="col m8 s12">
<h5 class="white-text"><%= __('blogroll') %></h5>
<% for (var name in site.data.link.extern) { %>
<a class="social-link" href="<%= site.data.link.extern[name] %>" target="_blank"><%= name %></a>
<% } %>
</div>
<% } %>
</div>
</div>
<% } %>
<div class="footer-copyright <%= theme.color.link %>-link-context">
<div class="container">
<%= theme.copyright %>
<p class="right" style="margin-top: 0;">Power By <a href="https://hexo.io">Hexo</a></p>
</div>
</div>
</footer>
@@ -0,0 +1,68 @@
<!DOCTYPE HTML>
<html>
<!--
..
.' @`._
~ ...._.' ,__.-;
_..------/` .-' ~
: __./' , .'-'--.._
~ `---(.-'''---. \`._ `. ~
_.--'( .______.'.-' `-.` `.
: `-..____`-. ;
`. ```` 稻花香里说丰年, ; ~
`-.__ 听取人生经验。 __.-'
````-----.......-----''' ~
~ ~
-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<%
var title = [];
if (page.current > 1) title.push(__('page', page.current));
if (page.title) title.push(page.title);
if (page.category) title.push(page.category);
if (page.tag) title.push(page.tag);
if (page.archive){
if (page.year) title.push(__('archive_b', page.year + (page.month ? '/' + page.month : '')));
else title.push(__('archive_a'));
}
title.push(config.subtitle);
%>
<title><%= title.join(' | ') %></title>
<% if (config.author){ %><meta name="author" content="<%= config.author %>"><% } %>
<% if (page.description){ %>
<meta name="description" content="<%= page.description %>">
<% } else if (config.description){ %>
<meta name="description" content="<%= config.description %>">
<% } else if (page.excerpt){ %>
<meta name="description" content="<%= strip_html(page.excerpt).replace(/^\s*/, '').replace(/\s*$/, '') %>">
<% } else if (page.content){ %>
<meta name="description" content="<%= strip_html(page.content).replace(/^\s*/, '').replace(/\s*$/, '').substring(0, 150) %>">
<% } %>
<% if (page.keywords){ %><meta name="keywords" content="<%= page.keywords %>"><% } %>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<% if (page.title){ %><meta property="og:title" content="<%= page.title %>"/><% } %>
<meta property="og:site_name" content="<%= config.title %>"/>
<% if(page.cover) { %>
<meta property="og:image" content="<%= page.cover %>" />
<% } else { %>
<meta property="og:image" content="<%= config.cover %>"/>
<% } %>
<link rel="icon" type="image/png" href="<%- config.root %>favicon.ico">
<link rel="alternate" href="<% if (theme.rss){ %><%- theme.rss %><% } else { %><%- config.root %>atom.xml<% } %>" title="<%= config.title %>" type="application/atom+xml">
<link rel="stylesheet" href="<%- config.root %>css/lib/materialize.min.css">
<link rel="stylesheet" href="<%- config.root %>css/lib/font-awesome.min.css">
<link rel="stylesheet" href="<%- config.root %>css/style.css" media="screen" type="text/css">
<% if (theme.google_code_prettify) { %>
<link rel="stylesheet" href="<%- config.root %>css/lib/<%= theme.google_code_prettify %>.css" type="text/css">
<% } else { %>
<link rel="stylesheet" href="<%- config.root %>css/lib/prettify_default.css" type="text/css">
<% } %>
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->
</head>
@@ -0,0 +1,23 @@
<nav class="<%= theme.color.header %>">
<div class="nav-wrapper">
<a href="#" data-activates="main-menu" class="button-collapse">
<i class="fa fa-navicon"></i>
</a>
<div class="">
<a href="/" class="brand-logo hide-on-med-and-down"><%= config.title %></a>
<ul class="right hide-on-med-and-down">
<% for (var i in theme.menu){ %>
<li>
<a class="<%= theme.menu[i].class %> <%= theme.menu[i].type ? theme.menu[i].type+'-menu' : '' %>" href="<%= theme.menu[i].link %>" <% if (theme.menu[i].type) { %>data-activates="<%=theme.menu[i].type %>-menu" <% } %>>
<i class="fa fa-<%= theme.menu[i].icon %> "></i>
<%= __('menu.' + theme.menu[i].id) %>
</a>
</li>
<% } %>
</ul>
<%- partial('side_nav') %>
</div>
</div>
</nav>
<%- partial('search') %>
@@ -0,0 +1,11 @@
<div class="mdl-layout__drawer">
<span class="mdl-layout-title"><%= config.title %></span>
<nav class="mdl-navigation">
<% for (var i in theme.menu){ %>
<a class="mdl-navigation__link" href="<%- theme.menu[i] %>">
<i class="material-icons" role="presentation"><%= theme.menu_icon[i] %></i>
<%= i %>
</a>
<% } %>
</nav>
</div>
@@ -0,0 +1,12 @@
<nav class="page-nav hide-on-small-only">
<div class="nav-wrapper <%= theme.color.page_nav %>">
<span class="breadcrumb"><%= nav_head %></span>
<% if (partial_path) { %>
<%- partial(partial_path) %>
<% } %>
<% if (archive_html) { %>
<%- archive_html %>
<% } %>
</div>
</nav>
@@ -0,0 +1,13 @@
<ul class="pagination center-align">
<li class="<%= page.current === 1 ? 'disabled' : '' %>">
<a href="<%- config.root %><%- page.prev_link %>"><i class="fa fa-angle-left"></i></a>
</li>
<% for (var i = 1; i <= page.total; i++) { %>
<li class="<%= page.current == i ? 'active ' + theme.color.pagination : 'waves-effect' %>"><a href="<%= i == 1 ? '/' : '/page/' + i %>"><%= i %></a></li>
<% } %>
<li class="<%= page.next_link === '' ? 'disabled' : '' %>">
<a href="<%- config.root %><%- page.next_link %>"><i class="fa fa-angle-right"></i></a>
</li>
</ul>
@@ -0,0 +1,16 @@
<% if (theme.google_analytics){ %>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<%= theme.google_analytics %>', 'auto');
ga('send', 'pageview');
</script>
<% } %>
<% if (theme.tencent_analytics){ %>
<script type="text/javascript" src="http://tajs.qq.com/stats?sId=<%= theme.tencent_analytics %>" charset="UTF-8"></script>
<% } %>
@@ -0,0 +1,66 @@
<%
var pageId = page.path;
var pageUrl = page.permalink;
var pageTitle = page.title;
%>
<% if (theme.disqus_shortname && page.comments){ %>
<section id="comment">
<div id="disqus_thread"></div>
<script>
var disqus_config = function() {
this.page.url = '<%= pageUrl %>';
this.page.identifier = '<%= pageId %>';
};
(function() {
var d = document,
s = d.createElement('script');
s.src = '//<%= theme.disqus_shortname %>.disqus.com/embed.js';
s.setAttribute('data-timestamp', + new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the
<a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a>
</noscript>
</section>
<% } else if (theme.duoshuo_shortname && page.comments){ %>
<section id="comment">
<div class="card">
<div class="card-content">
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-thread-key="<%= pageId %>" data-title="<%= pageTitle %>" data-url="<%= pageUrl %>"></div>
<script type="text/javascript">
console.log(document.querySelector('.ds-thread'));
var duoshuoQuery = {
short_name: '<%= theme.duoshuo_shortname %>'
};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';
ds.async = true;
ds.src = (document.location.protocol == 'https:'
? 'https:'
: 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->
</div>
</div>
</section>
<% } else if (theme.yungentie_product_key && page.comments){ %>
<div id="cloud-tie-wrapper" class="cloud-tie-wrapper"></div>
<script>
var cloudTieConfig = {
url: document.location.href,
sourceId: "",
productKey: "<%= theme.yungentie_product_key %>",
target: "cloud-tie-wrapper"
};
</script>
<script src="https://img1.cache.netease.com/f2e/tie/yun/sdk/loader.js"></script>
<% } %>
@@ -0,0 +1,10 @@
<% if (theme.mathjax) { %>
<script type="text/x-mathjax-config">
MathJax.Hub.Config({
tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']]}
});
</script>
<script type="text/javascript" async
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
<% } %>
@@ -0,0 +1,8 @@
<noscript>
<div class="noscript">
<p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
</div>
</noscript>
<div class="noscript">
<p class="center-align">当前网速较慢或者你使用的浏览器不支持博客特定功能,请尝试刷新或换用Chrome、Firefox等现代浏览器</p>
</div>
@@ -0,0 +1,15 @@
<% if (theme.page_stat) { %>
<script async src="//dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>
<div class="site-visitors-container white-text">
<span>
<i class="fa fa-user"></i>
<span class="busuanzi-value" id="busuanzi_value_site_uv"></span>
</span>
<span>&nbsp;|&nbsp;</span>
<span>
<i class="fa fa-eye"></i>
<span class="busuanzi-value" id="busuanzi_value_site_pv"></span>
</span>
</div>
<% } %>
@@ -0,0 +1,10 @@
<% if (item.categories && item.categories.length > 0){ %>
<%
var cats = [];
item.categories.forEach(function(cat){
cats.push('<a class="breadcrumb" href="' + config.root + cat.path + '">' + cat.name + '</a>');
});
%>
<%- cats.join('') %>
<% } %>
@@ -0,0 +1,18 @@
<div class="gallery carousel carousel-slider">
<% if (item.photos.length){ %>
<% item.photos.forEach(function(photo){ %>
<span class="carousel-item"><img class="carousel-image" src="<%- photo %>"></span>
<% }); %>
<% } else { %>
<img class="carousel-item" src="<%- item.photos %>">
<% } %>
<div class="control">
<div class="carousel-control prev">
<i class="fa fa-left"></i>
</div>
<div class="carousel-control next">
<i class="fa fa-right"></i>
</div>
</div>
</div>
@@ -0,0 +1,15 @@
<% if (item.prev) { %>
<p class="<%= theme.color.link %>-link-context">
<a href="<%= url_for(item.prev.path) %>" rel="next" title="<%= item.prev.title %>">
<%= __('prev', item.prev.title) %>
</a>
</p>
<% } %>
<% if (item.next) { %>
<p class="<%= theme.color.link %>-link-context">
<a href="<%= url_for(item.next.path) %>" rel="next" title="<%= item.next.title %>">
<%= __('next', item.next.title) %>
</a>
</p>
<% } %>
@@ -0,0 +1,6 @@
<% if (theme.page_stat) { %>
<span id="busuanzi_container_page_pv" class="read-times-container">
<i class="fa fa-eye"></i>
<span id="busuanzi_value_page_pv"></span>
</span>
<% } %>
@@ -0,0 +1,3 @@
<div class="toc <%= theme.color.link %>-link-context hide-on-med-and-down">
<%- toc(item.content, {class: 'section table-of-contents', list_number: false}) %>
</div>
@@ -0,0 +1,7 @@
<% if (item.tags && item.tags.length > 0){ %>
<div class="tags-row">
<% item.tags.forEach(function(tag) { %>
<a href="<%= config.root + tag.path %>" class="chip <%= theme.color.tag %>"><%= tag.name %></a>
<% }); %>
</div>
<% } %>
@@ -0,0 +1 @@
<time class="<%= theme.color.link %>-link-context" datetime="<%= item.date.toDate().toISOString() %>"><a href="<%- url_for(item.path) %>"><%= item.date.format(config.date_format) %></a></time>
@@ -0,0 +1,13 @@
<% if (item.link){ %>
<% if (item.title){ %>
<h1><a href="<%- item.link %>" target="_blank"><%= item.title || __('no_title') %></a></h1>
<% } else { %>
<h1><a href="<%- item.link %>" target="_blank"><%= item.link || __('no_title') %></a></h1>
<% } %>
<% } else { %>
<% if (index){ %>
<h1 class="<%= theme.color.article_title_link %>-link-context"><a href="<%- url_for(item.path) %>"><%= item.title || __('no_title') %></a></h1>
<% } else { %>
<h1><%= item.title || __('no_title') %></h1>
<% } %>
<% } %>
@@ -0,0 +1,9 @@
<div id="search" class="modal search-modal">
<div class="row">
<div class="input-field col s12">
<input id="search-input" type="text">
<label for="search-input"><%= __('menu.search') %></label>
</div>
</div>
<div id="search-result" class="search-result col s12"></div>
</div>
@@ -0,0 +1,79 @@
<div>
<ul class="side-nav <%= theme.color.side_nav %>" id="main-menu">
<% if (site.data.about) { %>
<li class="side-user">
<div class="row">
<div class="col s4 no-padding">
<img class="avatar-image circle responsive-img" src="<%= site.data.about.avatar %>" alt="User Avatar">
</div>
<div class="info col s8 valign-wrapper no-padding">
<div class="valign">
<p class="name"><%= site.data.about.name %></p>
<p class="desc"><%= site.data.about.tag %></p>
</div>
</div>
</div>
</li>
<% } %>
<% for (var i in theme.menu){ %>
<li class="no-padding item">
<a class="waves-effect <%= theme.menu[i].class %> <%= theme.menu[i].type ? theme.menu[i].type+'-menu' : '' %>" href="<%= theme.menu[i].link %>" <% if (theme.menu[i].type) { %>data-activates="<%=theme.menu[i].type %>-menu" <% } %>>
<i class="fa fa-<%= theme.menu[i].icon %> "></i>
<%= __('menu.' + theme.menu[i].id) %>
</a>
</li>
<% } %>
</ul>
<ul class="side-nav <%= theme.color.side_nav %>" id="category-menu">
<li><h4>分类</h4></li>
<%
var catTree = {};
site.categories.forEach(function(item) {
if(item.posts.length > 0) {
var cats = item.path.split('/');
var i, depth = 0;
var addTree = function(root, i) {
if(i + 1 > cats.length) {
return;
} else if(!root.hasOwnProperty(cats[i])) {
root[cats[i]] = {posts_num: item.posts.length};
addTree(root[cats[i]], i + 1);
} else {
addTree(root[cats[i]], i + 1);
}
};
addTree(catTree, 1);
}
});
var walk = function(root, path, depth) {
for(var item in root) {
if(item.length > 0 && item != 'posts_num') {
var space = '';
for(i = 0; i < depth; i++) {
space += '--';
}
%>
<li class="collapse-level-<%= depth %> item" collapse-level="<%= depth %>">
<a class="no-padding" href="<%- config.root %><%- path + item %>/">
<%= item %> <span class="right"><%= __('side_nav_paper', root[item]['posts_num']) %></span></a>
</a>
</li>
<%
walk(root[item], path + item + '/', depth + 1);
} // if
} // for
}; // function work
walk(catTree, 'categories/', 0);
%>
</ul>
<div class="side-nav <%= theme.color.side_nav %>" id="tag-menu">
<h4 style="padding:0 15px">标签</h4>
<% site.tags.forEach(function (item, index) { %>
<a href="<%= url_for(item.path) %>">
<%= item.name %> <span class="right"><%= __('side_nav_paper', item.length) %></span></a>
</a>
<% }); %>
</div>
</div>
@@ -0,0 +1,22 @@
<article class="simple-article">
<div class="card">
<div class="card-content">
<div class="article-title">
<%- partial('post/title') %>
</div>
<%- partial('post/time') %>
<%- partial('post/tag') %>
<% if (showEntry && item.excerpt && index) { %>
<div class="entry <%= theme.color.link %>-link-context">
<%- item.excerpt %>
</div>
<% } %>
</div>
<% if (item.excerpt) { %>
<div class="card-action <%= theme.color.link %>-link-context">
<a href="<%= "/" + item.path %>"><%= __('readmore') %></a>
</ div>
<% } %>
</div>
</article>
@@ -0,0 +1,18 @@
<% var sliders = site.data.slider; %>
<% if (sliders) { %>
<div class="slider">
<ul class="slides">
<% for (var i in sliders) { %>
<li>
<a href="<%= sliders[i].link || 'javascript:;' %>">
<img class="slider-image" src="<%= sliders[i].image %>">
<div class="caption <%= sliders[i].align %>-align">
<h4><%= sliders[i].title %></h3>
<h5 class="light grey-text text-lighten-3"><%= sliders[i].subtitle %></h5>
</div>
</a>
</li>
<% } %>
</ul>
</div>
<% } %>