Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加多说最新评论模块以及友情链接模块配置化 #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 20141203
1. modify widget/links, you can define links in `_config.yml`
2. add widget/comment, it will show the latest comments of duoshuo
3. linkedin icon in footer can be display right now
19 changes: 17 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ widgets:
- category
- tag
- rss
## provide six widgets:category,tag,rss,archive,tagcloud,links.
## modify links in `/layout/_widget/links.ejs`.
- comment
- links
## provide seven widgets:category,tag,rss,archive,tagcloud,links,comment.
## modify links in `_config.yml`

#### RSS
rss: ## RSS address.
Expand Down Expand Up @@ -96,3 +98,16 @@ google_cse:
## title: search
## ---

## for friendly links
links:
- url: http://github.com
name: github
title: a free code repository
- url: http://hexo.io
name: hexo
title: a free blog generator

# 百度统计
baidu_tongji:
enable: false ##使用百度统计就设置为true
key: ##百度统计代码中//hm.baidu.com/hm.js?后面的那串id
1 change: 1 addition & 0 deletions languages/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ rss: RSS
showsidebar: "Show Sidebar"
hidesidebar: "Hide Sidebar"
updated: Updated
comments: "Latest Comments"
3 changes: 2 additions & 1 deletion languages/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ links: 友情链接
rss: RSS 订阅
showsidebar: 显示侧边栏
hidesidebar: 隐藏侧边栏
updated: 更新日期
updated: 更新日期
comments: 最新评论
3 changes: 2 additions & 1 deletion languages/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ links: 友情鏈接
rss: RSS 訂閱
showsidebar: 顯示側邊欄
hidesidebar: 隱藏側邊欄
updated: 更新日期
updated: 更新日期
comments: 最新評論
23 changes: 22 additions & 1 deletion layout/_partial/after_footer.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,28 @@ $(document).ready(function(){
if($.fancybox){
$('.fancybox').fancybox();
}
});
});
</script>
<% } %>
<script type="text/javascript">
$(function() {
$('.article-content img').each(function() {
var me = $(this)
var alt = me.attr('alt')
if (alt) {
var link = $('<a />').attr({
title: alt,
href: me.attr('src'),
target: '__BLANK'
})
me.wrap(link)
var caption = $('<caption />').text(alt).css({
display: 'block',
textAlign: 'center'
})
me.after(caption)
}
})
})
</script>
<%- partial('google_analytics') %>
11 changes: 11 additions & 0 deletions layout/_partial/baidu_tongji.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<% if (theme.baidu_tongji && theme.baidu_tongji.enable) { %>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "//hm.baidu.com/hm.js?<%- theme.baidu_tongji.key %>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<% } %>
1 change: 1 addition & 0 deletions layout/_partial/head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@
<link rel="apple-touch-icon-precomposed" href="<%- config.root %><%- theme.apple_icon %>">
<% } %>
<%- css('css/style') %>
<%- partial('baidu_tongji') %>
</head>
18 changes: 18 additions & 0 deletions layout/_widget/comment.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<% if (theme.duoshuo.enable && theme.duoshuo.short_name.length) { %>
<div class="commentslist">
<p class="asidetitle"><%= __('comments') %></p>
<ul class="ds-recent-comments" data-num-items="5" data-show-avatars="0" data-show-time="1" data-show-admin="1" data-excerpt-length="32" data-show-title="1"></ul>
</div>
<!--多说js加载开始,一个页面只需要加载一次 -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"<%= theme.duoshuo.short_name %>"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = 'http://static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!--多说js加载结束,一个页面只需要加载一次 -->
<% } %>
7 changes: 5 additions & 2 deletions layout/_widget/links.ejs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<% if (theme.links && theme.links.length) { %>
<div class="linkslist">
<p class="asidetitle"><%= __('links') %></p>
<ul>
<li><a href="http://yangjian.me" target="_blank" title="YangJian">Alimon's Blog</a></li>
<li><a href="http://hexo.io" target="_blank" title="Hexo">Hexo</a></li>
<% theme.links.forEach(function(item) { %>
<li><a href="<%= item.url %>" target="_blank" title="<%= item.title %>"><%= item.name %></a></li>
<% }); %>
</ul>
</div>
<% } %>
29 changes: 29 additions & 0 deletions source/css/_partial/aside.styl
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,32 @@
color color-theme
transition color .25s

//comments
.commentslist
margin-top 0.5em
@media mini
width 45%
float left
margin 0 5% 0 0
@media tablet
width 100%
float none
margin 1em 0 0
ul
padding 0.5em 0
a
font-size 1em
line-height line-height
display block
padding 0
&:hover
color color-theme
transition color .25s

.ds-excerpt
font-size 1.1em
color color-theme

.ds-recent-comments
margin-top -0.6em
margin-left 0.3em
2 changes: 1 addition & 1 deletion source/css/_partial/footer.styl
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ footer
@media mini
width 18em
position absolute
right -3em
right -1em
top 3em
a
float left
Expand Down